init() time; the SDK uses it for three actions:
- User identification
- Tracking user data
- Cookie syncing
persistenceInCookieStorage) and replayed on subsequent events until changed.
For Default Opt-in and GDPR strategies, only Brand Consent is honored from
setConsent. The primary track, cookieSync, and identify fields are ignored — resolution comes from optOut or the TCF string. Primary fields only apply when using the Custom strategy.Default opt-in
Use this when you don’t have a CMP and consent is conveyed by your own server-side logic. SetoptOut directly:
| Function | Type | Value | Description |
|---|---|---|---|
optOut | Boolean | false | Explicit consent signal. When true, the SDK is fully suppressed — no identification, no cookie sync, no event capture. |
setConsent:
GDPR TCF 2.0
Use this when your site has a TCF 2.0 CMP. The SDK automatically queries the TCF API for the publisher’s consent before recording events.| Option | Type | Default | Description |
|---|---|---|---|
useConsent | Boolean | true | SDK waits for a consent signal before recording. |
checkForCMP | Boolean | true | Queries the TCF API on the page. Set false to use setConsent instead. |
purposesForTracking | number[] | [1,3,4] | TCF purpose IDs that must be allowed to enable tracking. |
purposesForCookieSyncing | number[] | [1,3,4] | TCF purpose IDs that must be allowed to enable cookie syncing. |
Custom consent
Use this when you want full control over consent — nooptOut shortcut, no TCF API. Supply consent explicitly via setConsent.
setConsent and uses them to gate every SDK action. Decisions are persisted until a new setConsent call overrides them.
setConsent — full signature
| Parameter | Type | Default | Required | Description |
|---|---|---|---|---|
value | Object | — | Yes | { primaryConsent, brandConsent }. Primary keys: track, cookieSync, identify. Any other key is treated as brand consent. |
[expiry] | Number | 365 | No | Days the consent is valid. |
Basic vs granular consent
Basic — one decision applied to all primary purposes:Granular consent can be expressed under any strategy, but primary fields (
track, cookieSync, identify) are only honored under Custom. Brand consent fields work everywhere.Recommended format
Send both primary and brand consent in a single call:Primary consent keys
| Key | Type | Description |
|---|---|---|
track | Boolean | If true, user data can be tracked. |
cookieSync | Boolean | If true, cookie syncs fire with configured channels. |
Choosing a strategy
Default opt-in
No CMP, simple boolean control via
optOut.GDPR TCF 2.0
You already have a TCF 2.0 CMP on the page.
Custom
You want granular control and your own consent UI.