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).
What consent changes
| Before consent | After consent | |
|---|---|---|
| Session id | in memory | also in sessionStorage (<prefix>tsid) – survives reloads for 30 min |
| Screen width / touch | not read | read |
| First-touch attribution | not stored | stored when firstTouch.enabled |
_fbp, _fbc, _ttp | not read | read and sent for conversion matching; created when missing (see below) |
Visitor id x3_vid | none – every visit is a new journey unless a click id or form links it | stored for 13 months, links visits into a customer journey |
Click ids x3_clk | taken from the URL of the current session only | kept for 90 days with the time of the first click |
identify() | not sent (default) | sent |
require mode | nothing measured | measurement starts |
Denying consent after granting removes the stored session id and everything listed under Journeys after consent.
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" } }| Name | What | Lifetime | Setting |
|---|---|---|---|
x3_vid | random first-party visitor id (UUID), renewed on every visit | 13 months | visitorId |
x3_clk | click ids from the URL (gclid, gbraid, wbraid, fbclid, li_fat_id, ttclid, msclkid) with the time first seen, plus which ad cookies the SDK created | 90 days | clickIds |
_fbp | Meta browser id fb.1.<ms>.<random>, created when missing, expiry renewed per visit | 90 days | adCookies |
_fbc | Meta click id fb.1.<first click ms>.<fbclid> – the time of the first click with that fbclid is kept across visits | 90 days | adCookies |
_ttp | TikTok browser id, created when missing | 90 days | adCookies |
adCookies: "auto"creates_fbp/_fbconly when a Meta destination is enabled and_ttponly when a TikTok destination is enabled;"always"creates them regardless;"off"only reads what your pixels set.- **Where
x3_vidlives**: behind the Next.js proxy it is an HttpOnly cookie the proxy sets onPOST {host}/v1/idand 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,Secureon HTTPS. - The script tag (
x3.js) downloads the smallx3.journeys.jsplugin only on a consent decision;x3.full.jscontains it and the npm build imports it on demand. - Revocation (
x3("consent", "denied"), a denial from the window event or a CMP): the SDK deletesx3_vid,x3_clkand the ad cookies it created (never your pixel's own cookies), asks the proxy to delete its HttpOnlyx3_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.
Telling 3x about consent
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");
2. A consent key in localStorage
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
storagePaththe stored text is compared first (accepted), then a JSON string ("accepted"). - A boolean at the path (
true/false) counts as granted/denied, unlessgrantedValues/deniedValuesname"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 readdocument.cookiebefore 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:
| CMP | Signal used |
|---|---|
| Cookiebot | Cookiebot.consent.statistics, events CookiebotOnAccept / CookiebotOnDecline |
| Usercentrics | consent for the analytics category via UC_UI events |
| Complianz | cmplz_status_change events, category statistics |
| Borlabs Cookie | borlabs-cookie-consent-saved, group statistics |
| Google Consent Mode | analytics_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 andnavis alwaysload; 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. Ongrantedthe 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).