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 AdjustConfig
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 AdjustConfig
instance and pass the following parameters:
context
(Context
): The Android Context in which your app is running. Passthis
to get the current app context.appToken
(String
): Your Adjust app token.environment
(String
): The environment you want to run the SDK in. PassAdjustConfig.ENVIRONMENT_SANDBOX
to run the SDK in sandbox mode for testing. PassAdjustConfig.ENVIRONMENT_PRODUCTION
to run the SDK in production mode for release.allowSuppressLogLevel
(Boolean
): Whether to suppress all logging. Set totrue
to suppress logging orfalse
to enable logging.
Read-only configuration
Read-only configuration options are set in your AdjustConfig
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 Adjust.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 level | Description |
---|---|
LogLevel.VERBOSE | Enable all logging |
LogLevel.DEBUG | Enable debug logging |
LogLevel.INFO | Only show info level logging (default option) |
LogLevel.WARN | Disable informational warnings |
LogLevel.ERROR | Disable warning level logging and below |
LogLevel.ASSERT | Disable error level logging and below |
LogLevel.SUPPRESS | Suppress all logging |
You can set your log level by calling the setLogLevel
method on your AdjustConfig
instance with the following parameter:
logLevel
(LogLevel
): The log level you want to use.
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
(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.
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.
Set default link token
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.
Enable cost data sending
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 enableCostDataInAttribution
method.
Cost data is accessible in the user’s attribution information.
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 AdjustConfig.enableSendingInBackground
method.
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 Adjust.switchToOfflineMode
method.
Deactivate offline mode
You can re-enable the SDK by calling the Adjust.switchBackToOnlineMode
method. This prompts the SDK to resume sending information.
Set push tokens
Push tokens are used for Audiences and client callbacks. They’re also required for Uninstall and reinstall measurement.
Your config object contains a string pushToken
property that you can use to store your push token. You can update this property at any time by calling the setPushToken
method and passing the following arguments:
token
(String
): Your push token.context
(Context
): The Android Context in which your app is running. PassgetApplicationContext()
to get the current app context.
Disable the SDK
The Adjust SDK runs by default when your app is open. You can disable the Adjust SDK to pause sending information to Adjust by calling the Adjust.disable
method. When you disable the Adjust SDK, it doesn’t send any data to Adjust’s servers.
Enable the SDK
If you’ve disabled the SDK and want to re-enable it, call the Adjust.enable
method. When the SDK is enabled, it will send information to Adjust’s servers.
Check SDK enabled status
If you want to check whether the Adjust SDK is currently enabled, you can pass a callback function to the Adjust.isEnabled
method to return this information asynchronously.