Consent and CMPs

3x measures without consent in the default cookieless mode and upgrades when consent is granted. Which device reads happen before and after consent is listed in Privacy and GDPR; choose the project's mode there (cookieless, strict, require).

Before consentAfter consent
Session idin memoryalso in sessionStorage (<prefix>tsid) – survives reloads for 30 min
Screen width / touchnot readread
First-touch attributionnot storedstored when firstTouch.enabled
_fbp, _fbc, _ttpnot readread and sent for conversion matching; created when missing (see below)
Visitor id x3_vidnone – every visit is a new journey unless a click id or form links itstored for 13 months, links visits into a customer journey
Click ids x3_clktaken from the URL of the current session onlykept for 90 days with the time of the first click
identify()not sent (default)sent
require modenothing measuredmeasurement starts

Denying consent after granting removes the stored session id and everything listed under Journeys after consent.

Before consent – and for visitors who never consent – the SDK stores nothing on the device. After consent it keeps what links a visitor's sessions into a customer journey and improves conversion matching. The project setting tracking.journeys controls it (default: everything on, ad cookies auto):

{ "journeys": { "visitorId": true, "clickIds": true, "adCookies": "auto" } }
NameWhatLifetimeSetting
x3_vidrandom first-party visitor id (UUID), renewed on every visit13 monthsvisitorId
x3_clkclick ids from the URL (gclid, gbraid, wbraid, fbclid, li_fat_id, ttclid, msclkid) with the time first seen, plus which ad cookies the SDK created90 daysclickIds
_fbpMeta browser id fb.1.<ms>.<random>, created when missing, expiry renewed per visit90 daysadCookies
_fbcMeta click id fb.1.<first click ms>.<fbclid> – the time of the first click with that fbclid is kept across visits90 daysadCookies
_ttpTikTok browser id, created when missing90 daysadCookies
  • adCookies: "auto" creates _fbp/_fbc only when a Meta destination is enabled and _ttp only when a TikTok destination is enabled; "always" creates them regardless; "off" only reads what your pixels set.
  • **Where x3_vid lives**: behind the Next.js proxy it is an HttpOnly cookie the proxy sets on POST {host}/v1/id and injects into each batch – a server-set cookie that Safari's ITP does not cap at 7 days. With any other proxy (nginx, Cloudflare Worker, Netlify, CNAME) or without a proxy the SDK falls back to a JavaScript cookie (Safari caps script-set cookies at 7 days, so returning Safari visitors link less often).
  • Cookies go to the site's registrable domain (example.com), SameSite=Lax, Secure on HTTPS.
  • The script tag (x3.js) downloads the small x3.journeys.js plugin only on a consent decision; x3.full.js contains it and the npm build imports it on demand.
  • Revocation (x3("consent", "denied"), a denial from the window event or a CMP): the SDK deletes x3_vid, x3_clk and the ad cookies it created (never your pixel's own cookies), asks the proxy to delete its HttpOnly x3_vid, and immediately stops sending visitor id, click ids and ad cookies. A batch without consent also makes the Next.js proxy delete its cookie.

Pick whatever your banner offers – several can be combined.

1. Call the API

// after the visitor accepted
x3("consent", "granted");
// after the visitor declined or withdrew
x3("consent", "denied");

With npm: import { consent } from "@x3growth/sdk"; consent("granted");

If your banner stores its decision in localStorage, configure the key and values (Settings → Tracking → Consent):

{ "consent": { "mode": "cookieless", "storageKey": "cookie_consent", "grantedValues": ["accepted", "all"], "deniedValues": ["declined", "necessary"] } }

The SDK reads this key on start (reading the consent state is allowed without consent).

Many banners store an object instead of a plain value, e.g. {"analytics":true,"marketing":false} or {"categories":{"statistics":"accepted"}}. Point storagePath (a dotted path, like detailPath) at the field that decides about analytics:

{ "consent": { "mode": "cookieless", "storageKey": "cmp_state", "storagePath": "categories.statistics", "grantedValues": ["accepted"], "deniedValues": ["rejected"] } }
  • Without storagePath the stored text is compared first (accepted), then a JSON string ("accepted").
  • A boolean at the path (true/false) counts as granted/denied, unless grantedValues/deniedValues name "true" or "false" themselves.
  • A missing field or an unknown value stays pending.
  • If the banner keeps its decision in a cookie instead of localStorage, add "storageSource": "cookie" (the cookie value may be URL-encoded JSON). Only then does the SDK read document.cookie before consent.

3. A window event

{ "consent": { "windowEvent": { "name": "cookieConsent", "detailPath": "", "grantedValues": ["accepted"], "deniedValues": ["declined"] } } }

detailPath is a dotted path into event.detail ("" = the detail itself).

4. Built-in CMP adapters

Set consent.cmp to any of cookiebot, usercentrics, complianz, borlabs, google_consent_mode. The adapter plugin (x3.consent.js) is loaded lazily and maps the CMP's statistics/analytics category to 3x consent:

CMPSignal used
CookiebotCookiebot.consent.statistics, events CookiebotOnAccept / CookiebotOnDecline
Usercentricsconsent for the analytics category via UC_UI events
Complianzcmplz_status_change events, category statistics
Borlabs Cookieborlabs-cookie-consent-saved, group statistics
Google Consent Modeanalytics_storage from the dataLayer consent state

With npm, bridgeCmp(name) from @x3growth/sdk/presets subscribes one adapter without project config; the implementations are exported as CMP_ADAPTERS (Presets entry point).

Global Privacy Control and Do Not Track

respectGlobalPrivacyControl (default on for new projects) treats navigator.globalPrivacyControl and the Sec-GPC request header as denied: cookieless measurement continues, nothing is upgraded.

respectDoNotTrack (project setting, or init({ respectDoNotTrack: true }) / data-respect-dnt) is stricter: when the browser sends DNT the SDK does not track at all. As a server-side safeguard the API treats any batch with a DNT: 1 header as denied when the project setting is on.

Strict and require modes

  • strict: before consent, pageviews carry no viewport or scroll data and nav is always load; section reach and engaged time need consent. Clicks, custom events and video of your own elements still work. Batches without dimensions are accepted (bots are filtered by user agent).
  • require: the SDK loads, reads the consent state, and waits. On granted the first pageview starts.

Server-side

POST /v1/projects/{project}/events and conversions from your server are independent of browser consent; your legal basis decides (Legal basis).