adjust-icon

Configuration

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

Instantiate your config object

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 (std::string)

YourAdjust app token.

environment (std::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.

You can also pass the following optional parameter:

allowSuppressLogLevel (bool)

Whether to suppress all logging. Set totrueto suppress logging orfalseto enable logging.

#include "Adjust/Adjust2dx.h"
std::string appToken = "{YOUR_APP_TOKEN}";
std::string environment = AdjustEnvironmentSandbox2dx;
AdjustConfig2dx adjustConfig = AdjustConfig2dx(appToken, environment, false);
Adjust2dx::initSdk(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::initSdk.

Set your logging level

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 = "{YOUR_APP_TOKEN}";
std::string environment = AdjustEnvironmentSandbox2dx;
AdjustConfig2dx adjustConfig = AdjustConfig2dx(appToken, environment);
adjustConfig.setLogLevel(AdjustLogLevel2dxVerbose);
Adjust2dx::initSdk(adjustConfig);

Set external device identifier

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 (std::string)

Your external device identifier. This value iscase 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("1a42b171-faa5-46da-b5ae-6f4be6d05167");
Adjust2dx::initSdk(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.

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 of your AdjustConfig2dx instance with the following argument:

defaultTracker (std::string)

TheAdjust link tokenyou want to record preinstalled installs against.

AdjustConfig2dx adjustConfig = AdjustConfig2dx(appToken, environment);
adjustConfig.setDefaultTracker("abc123");
Adjust2dx::initSdk(config);

Receive ad spend data in attribution

By default, the Adjust SDK doesn't send ad spend data as part of a user's attribution. You can configure the SDK to send this data by enabling cost data sending. To enable ad spend data sending, call the enableCostDataInAttribution() method of your AdjustConfig2dx instance.

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

AdjustConfig2dx adjustConfig = AdjustConfig2dx(appToken, environment);
adjustConfig.enableCostDataInAttribution();
Adjust2dx::initSdk(config);

Enable background recording

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 enableSendingInBackground method of your AdjustConfig2dx instance.

AdjustConfig2dx adjustConfig = AdjustConfig2dx(appToken, environment);
adjustConfig.enableSendingInBackground();
Adjust2dx::initSdk(adjustConfig);

Dynamic configuration

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

Activate offline mode

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 Adjust2dx::switchToOfflineMode method.

Adjust2dx::switchToOfflineMode();

Deactivate offline mode

You can re-enable the SDK by calling the Adjust2dx::switchBackToOnlineMode method. This prompts the SDK to resume sending information.

Adjust2dx::switchBackToOnlineMode();

Set push tokens

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

You can update your push token at any time by calling the Adjust2dx::setPushToken method with the following argument:

pushtoken (std::string)

Your push token.

Adjust2dx::setPushToken("push-token");

Disable the SDK

The Adjust SDK runs by default when your app is open. You can disable the Adjust SDK to stop sending information to Adjust by calling the Adjust2dx::disable method. When you disable the Adjust SDK, no data is sent to Adjust and no information is recorded by the SDK. This means that any Adjust method called when the SDK is disabled won't record anything.

Adjust2dx::disable();

Enable the SDK

If you've disable the SDK and want to re-enable it, call the Adjust2dx::enable method. When the SDK is enabled, it will send information to Adjust's servers.

Adjust2dx::enable();

Check enabled status

You can check if the Adjust SDK is enabled at any time by calling the Adjust2dx::isEnabled method and passing a callback function. The status is returned asynchronously and passed to your callback function as a bool value.

Adjust2dx::isEnabled([](bool isEnabled) {
// process isEnabled
});