Configuration
Use the methods in this guide to configure the behavior of the Adtrace Web SDK.
The SDK supports two kinds of configuration:
| Type | When you set it | Can change after init? |
|---|---|---|
| Read-only | In Adtrace.initSdk({ ... }) on first load | No |
| Dynamic | On Adtrace at any time after initSdk | Yes |
Initialize the SDK
Read-only options are passed to Adtrace.initSdk. Call it as early as possible on each page load.
Required parameters
| Parameter | Type | Description |
|---|---|---|
appToken | string | Your Adtrace app token from the Adtrace panel. |
environment | string | Use sandbox for testing or production for release traffic. |
Example
initSdk
Adtrace.initSdk({
appToken: '{YourAppToken}',
environment: 'sandbox',
logLevel: 'verbose',
});
Set optional read-only parameters in the same object before the SDK starts. See the pages below for each option.
Important
For proper attribution, call setReferrer as close as possible to SDK initialization.
Read-only configuration
Set these in initSdk before the SDK sends the first session.
Set log level
verbose, info, warning, error, none, and on-screen logOutput
Set external device ID
Custom device or user identifier for deduplication
Set default tracker
Override the Organic tracker for unattributed traffic
Set namespace
Isolate SDK storage when multiple apps share a domain
Event deduplication limit
Cache size for deduplicationId on events
Data residency
EU, TR, or US data storage region
Custom URL
Redirect SDK requests to a custom endpoint
Dynamic configuration
Change these at runtime after initSdk.