adjust-icon

Configuration

You can configure the behavior of the Adjust SDK by assigning properties in the Adjust.initSdk method.

Required configuration

Method signature
function initSdk({ logLevel, logOutput, ...options }: InitOptions): void;

To configure the Adjust SDK, you need to call the Adjust.initSdk method with the following arguments:

  • appToken (string): Your Adjust app token.
  • environment (string): The environment you want to run the SDK in. Pass sandbox to run the SDK in sandbox mode for testing. Pass production to run the SDK in production mode for release.
Adjust.initSdk({
appToken: "YOUR_APP_TOKEN",
environment: "sandbox",
});

Logging options

Interface declaration
export type LogOptionsT = $ReadOnly<
$Shape<{|
logLevel: "none" | "error" | "warning" | "info" | "verbose",
logOutput: string,
|}>
>;

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

ValueDescription
verboseEnable full logging
infoReturn information, warnings, and error logs
warningReturn warnings and error logs
errorReturn only error logs
noneDisable all logging

You can set the log level by specifying an logLevel argument in the initSdk method. The SDK defaults to error if no value is passed.

Adjust.initSdk({
appToken: "YOUR_APP_TOKEN",
environment: "sandbox",
logLevel: "verbose",
});

Set log output

You can delegate a log output location in your web app to show logs directly on the screen. To do this, specify an HTML selector in the logOutput argument in the initSdk method. The SDK logs will print to this container.

Adjust.initSdk({
appToken: "YOUR_APP_TOKEN",
environment: "sandbox",
logOutput: "#logDiv",
});

Initialization options

Interface declaration
export type InitOptionsT = $ReadOnly<
$Shape<{|
appToken: $PropertyType<BaseParamsT, "appToken">,
environment: $PropertyType<BaseParamsT, "environment">,
defaultTracker: $PropertyType<BaseParamsT, "defaultTracker">,
externalDeviceId: $PropertyType<BaseParamsT, "externalDeviceId">,
customUrl: $PropertyType<CustomConfigT, "customUrl">,
dataResidency: $PropertyType<CustomConfigT, "dataResidency">,
urlStrategy: $PropertyType<CustomConfigT, "urlStrategy">,
eventDeduplicationListLimit: $PropertyType<
CustomConfigT,
"eventDeduplicationListLimit"
>,
namespace: $PropertyType<CustomConfigT, "namespace">,
attributionCallback: (string, Object) => mixed,
|}>
>;

Set external device identifier

Property declaration
externalDeviceId: string;

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. Pass your external device ID as the externalDeviceId argument in your Adjust.initSdk call.

Adjust.initSdk({
appToken: "YOUR_APP_TOKEN",
environment: "sandbox",
externalDeviceId: "YOUR_EXTERNAL_DEVICE_ID",
});

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.

Property declaration
defaultTracker: string;

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. Pass your token in the defaultTracker argument of your Adjust.initSdk call.

Adjust.initSdk({
appToken: "YOUR_APP_TOKEN",
environment: "sandbox",
defaultTracker: "YOUR_LINK_TOKEN",
});

Set storage namespace

Property declaration
namespace: string;

The Adjust SDK creates a storage namespace to store data in by default. You can override this an specify a custom namespace if you want to control where the data ends up.

Any data that the SDK has stored in the default namespace will be moved the custom namespace when it’s set.

You can set an custom namespace by specifying a namespace property in the initSdk method.

Adjust.initSdk({
appToken: "YOUR_APP_TOKEN",
environment: "sandbox",
namespace: "myCustomNamespace",
});

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
function switchToOfflineMode(): void;

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 the browser’s IndexedDB, or in localStorage if IndexedDB isn’t supported.

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

Adjust.switchToOfflineMode();

Event buffering

Method signature
function switchBackToOnlineMode(): void;

The SDK sends all saved information to Adjust’s servers when you disable offline mode. To do this, call the switchBackToOnlineMode method.

Adjust.switchBackToOnlineMode();

Disable the SDK

function stop(): void;

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 disable the SDK at any time by calling the stop method.

Adjust.stop();

Reenable the SDK

function restart(): void;

You can restart the SDK at any time by calling the restart method.

Adjust.restart();