Initialization

The initialization process sets up the core Interactions SDK, configuring its identity management, consent status, and loading the sitemap. This process must complete successfully before the SDK can begin collecting data.

The recommended flow follows a general pattern: first, initialize the SDK with necessary configurations (using init()), and then, load the sitemap (using initSitemap()).

The init() method initializes the Interactions SDK, accepting a configuration object (sdkConfig) and returning a Promise that resolves when the SDK is successfully initialized and ready.

This table shows the fields that the required sdkConfig object accepts for initializing the SDK.

Field NameField TypeDescription
consentsConsent[] or Promise<Consent[]>Required. A list of consent data values or a Promise that resolves a list of consent data values. The SDK waits for the Promise to resolve before tracking.
cookieDomainstringThe domain used for the first-party cookies that store identity data. Defaults to the current site's domain.

You can initialize the SDK based on how and when you receive consent.

Asynchronously with a Promise

Use a Promise when waiting for a user action (like clicking an opt-in button) or for a third-party Consent Management Platform (CMP) to load.

Synchronously with Pre-Configured Consent

If consent is available immediately (for example, when consent is loaded from a session cookie), you can pass the array directly.

Initializing with No Consent

If the user has not made a decision, pass an empty array. The SDK will not track until consent is updated later via updateConsents().

Use the reinit() method forces the SDK to reinitialize its state and re-run sitemap evaluation. This is useful for Single Page Applications (SPAs) where the content and URL change without a full page reload. Calling reinit() ensures the sitemap is re-evaluated to match the new virtual page.

Here's an example of using the reinit() method to reinitialize the SDK.