adjust-icon

Configuration

Use the methods in this document to configure the behavior of the Adjust SDK.

Instantiate your config object

Method signature
ADJConfig2dx(std::string appToken, std::string environment, bool allowSuppressLogLevel, std::string sdkPrefix) {
initConfig(appToken, environment, allowSuppressLogLevel, sdkPrefix);
}

To configure the Adjust SDK, you need to instantiate an AdjustConfig2dx object. This object contains the read-only configuration options that you need to pass to the Adjust SDK.

To instantiate your config object, create a new AdjustConfig2dx instance and pass the following parameters:

  • appToken (String): Your Adjust app token.
  • environment (String): The environment you want to run the SDK in. Pass AdjustEnvironmentSandbox2dx to run the SDK in sandbox mode for testing. Pass AdjustEnvironmentProduction2dx to run the SDK in production mode for release.
  • allowSuppressLogLevel (Boolean): Whether to suppress all logging. Set to true to suppress logging or false to enable logging.
#include "Adjust/Adjust2dx.h"
// ...
std::string appToken = "{YourAppToken}";
std::string environment = AdjustEnvironmentSandbox2dx;
AdjustConfig2dx adjustConfig = AdjustConfig2dx(appToken, environment, false);
Adjust2dx::start(adjustConfig);

Read-only configuration

Read-only configuration options are set in your AdjustConfig2dx instance before the initialization of the SDK. They can’t be changed while the SDK is running. You MUST configure any options you want to use before running Adjust2dx::start().

Set your logging level

Method signature
void setLogLevel(ADJLogLevel2dx logLevel);

The Adjust SDK provides configurable log levels to return different amounts of information. The following log levels are available:

Log levelDescription
AdjustLogLevel2dxVerboseEnable all logging
AdjustLogLevel2dxDebugEnable debug logging
AdjustLogLevel2dxInfoOnly show info level logs (default option)
AdjustLogLevel2dxWarnDisable info logging
AdjustLogLevel2dxErrorDisable warning level logging and below
AdjustLogLevel2dxAssertDisable error level logging and below
AdjustLogLevel2dxSuppressSuppress all logging

You can set your log level by calling the setLogLevel method on your AdjustConfig2dx instance with the following parameter:

  • logLevel (ADJLogLevel2dx): The log level you want to use.
std::string appToken = "{YourAppToken}";
std::string environment = AdjustEnvironmentSandbox2dx;
AdjustConfig2dx adjustConfig = AdjustConfig2dx(appToken, environment, false);
adjustConfig.setLogLevel(AdjustLogLevel2dxSuppress);
Adjust2dx::start(adjustConfig);

Set external device identifier

Method signature
void setExternalDeviceId(std::string externalDeviceId);

An external device identifier is a custom value that you can assign to a device or user. They help you recognize users across sessions and platforms. They can also help you deduplicate installs by user so that a user isn’t counted as duplicate new installs. Contact your Adjust representative to get started with external device IDs.

You can use an external device ID as a custom identifier for a device. This helps you keep continuity with your other systems. You can set property calling the setExternalDeviceId method with the following parameter:

  • externalDeviceId (String): Your external device identifier. This value is case sensitive. If you have imported external device IDs, make sure the value you pass matches the imported value.
AdjustConfig2dx adjustConfig = AdjustConfig2dx(appToken, environment);
adjustConfig.setExternalDeviceId("{Your-External-Device-Id}");
Adjust2dx::start(adjustConfig);

If you want to use the external device ID in your business analytics, you can pass it as a session callback parameter.

You can import existing external device IDs into Adjust. This ensures that the Adjust servers match future data to your existing device records. Contact your Adjust representative for more information.

Method signature
void setDefaultTracker(std::string defaultTracker);

You can configure a default link token if your app is preinstalled on a device. When a user opens the preinstalled app for the first time, the install is attributed to the default link token. To set your default link token, call the setDefaultTracker method with the following argument:

  • defaultTracker (String): The Adjust link token you want to record preinstalled installs against.
AdjustConfig2dx adjustConfig = AdjustConfig2dx(appToken, environment);
adjustConfig.setDefaultTracker("{TrackerToken}");
Adjust2dx::adjustConfig(config);

Enable cost data sending

Method signature
void setNeedsCost(bool needsCost);

By default, the Adjust SDK doesn’t send cost data as part of a user’s attribution. You can configure the SDK to send this data by enabling cost data sending. To enable cost data sending, call the setNeedsCost method on your config instance with the following parameter:

  • needsCost (Boolean): set to true to enable cost data sending or false to disable cost data sending.

Cost data is accessible in the user’s attribution information.

AdjustConfig2dx adjustConfig = AdjustConfig2dx(appToken, environment);
adjustConfig.setNeedsCost(true);
Adjust2dx::adjustConfig(config);

Enable background recording

Method signature
void setSendInBackground(bool isEnabled);

By default, the Adjust SDK pauses the sending of requests when your app is running in the background. You can configure the SDK to send requests in the background by enabling the background recording. To enable background recording, call the setSendInBackground method on your config instance with the following parameter:

  • isEnabled (Boolean): Set to true to enable background sending or false to disable background sending.
std::string appToken = "{YourAppToken}";
std::string environment = AdjustEnvironmentSandbox2dx;
AdjustConfig2dx adjustConfig = AdjustConfig2dx(appToken, environment);
adjustConfig.setLogLevel(AdjustLogLevel2dxVerbose);
adjustConfig.setSendInBackground(true);
Adjust2dx::start(adjustConfig);

Enable event buffering

Method signature
void setEventBufferingEnabled(bool isEnabled);

The Adjust SDK sends event information as soon as a user triggers an event in your app. You can send event information on a schedule by enabling event buffering. Event buffering stores events in a local buffer on the device and sends all requests once per minute.

Your config object contains a boolean eventBufferingEnabled property that controls this behavior. To enable event buffering, assign a Boolean value to the eventBufferingEnabled property of your config instance.

  • isEnabled (Boolean): Set to true to enable event buffering or false to disable event buffering.
std::string appToken = "{YourAppToken}";
std::string environment = AdjustEnvironmentSandbox2dx;
AdjustConfig2dx adjustConfig = AdjustConfig2dx(appToken, environment);
adjustConfig.setLogLevel(AdjustLogLevel2dxVerbose);
adjustConfig.setEventBufferingEnabled(true);
Adjust2dx::start(adjustConfig);

Delay the start of the SDK

Method signature
void setDelayStart(double delayStart);

By default, the Adjust SDK starts as soon as your app opens. If you want to send data that’s not available at launch in session parameters, you can delay the start of the SDK. This can be helpful if you are sending information such as unique identifiers.

To configure a startup delay, call the setDelayStart method with the following argument:

  • delayStart (Double): The time (in seconds) by which to delay the start of the SDK. You can delay the start of the SDK by up to 10 seconds.
std::string appToken = "{YourAppToken}";
std::string environment = AdjustEnvironmentSandbox2dx;
AdjustConfig2dx adjustConfig = AdjustConfig2dx(appToken, environment);
adjustConfig.setLogLevel(AdjustLogLevel2dxVerbose);
adjustConfig.setDelayStart(5.5);
Adjust2dx::start(adjustConfig);

Dynamic configuration

Dynamic configuration options may be changed during the SDK’s lifecycle in response to events or actions taken by the user.

Toggle offline mode

Method signature
static void setOfflineMode(bool isOffline);

The Adjust SDK sends event and session data to Adjust’s servers in real time. You can pause the sending of information by putting the SDK in offline mode. In offline mode the SDK stores all data in a local file on the device. The SDK sends this information to Adjust’s servers when you disable offline mode.

You can toggle offline mode at any time by calling the setOfflineMode method with the following argument:

  • isOffline (Boolean): Set to true to enable offline mode or false to disable offline mode.
Adjust2dx::setOfflineMode(true);

Set push tokens

Method signature
static void setDeviceToken(std::string deviceToken);

Push tokens are used for Audiences and client callbacks. They’re also required for Uninstall and reinstall tracking.

Your config object contains a string deviceToken property that you can use to store your push token. You can update this property at any time by calling the setDeviceToken method and passing the following arguments:

  • deviceToken (String): Your push token.
Adjust2dx::setDeviceToken("YourPushNotificationToken");

Disable or enable the SDK

Method signature
static void setEnabled(bool isEnabled);

The Adjust SDK runs by default when your app is open. You can disable and re-enable the Adjust SDK to pause and resume recording. When you disable the Adjust SDK, it doesn’t send any data to Adjust’s servers.

You can enable or disable the SDK at any time by calling the setEnabled method with the following argument:

  • isEnabled (Boolean): Set to true to enable the SDK or false to disable the SDK.
Adjust2dx::setEnabled(false);

Check enabled status

Method signature
static bool isEnabled();

You can check if the Adjust SDK is enabled at any time by calling the isEnabled method. This method returns a boolean value indicating if the SDK is enabled (true) or disabled (false).

Adjust2dx::isEnabled();