Appearance
Consent cookie & events
Reference for wiring your own code — or Google Tag Manager — to the visitor's consent decision. Use this when the Consent Mode toggles and category gating don't cover what you need.
Consent events
The banner dispatches these on window as CustomEvents:
| Event | Fires when |
|---|---|
cc:onFirstConsent | the visitor makes their first-ever choice |
cc:onConsent | on first consent and on every page load with a stored choice |
cc:onChange | the visitor changes an existing choice |
cc:onModalShow / cc:onModalHide | the banner or preferences modal opens / closes |
For gating a tag, cc:onConsent (does the visitor consent now, including on return visits) plus cc:onChange (they just changed their mind) is the pair you want.
Payload
js
window.addEventListener('cc:onConsent', (e) => {
e.detail.cookie.categories // e.g. ['necessary', 'analytics']
e.detail.cookie.consentId // stable random visitor id
e.detail.cookie.consentTimestamp
})
window.addEventListener('cc:onChange', (e) => {
e.detail.cookie.categories // the full current set
e.detail.changedCategories // just what flipped this time
})categories is the array to check. The standard keys are necessary, preferences, analytics and marketing; a site may define others.
Example: gate your own SDK
js
let started = false
function sync(categories) {
const wanted = categories.includes('analytics')
if (wanted && !started) { startAnalyticsSdk(); started = true }
if (!wanted && started) { stopAnalyticsSdk(); started = false }
}
window.addEventListener('cc:onConsent', (e) => sync(e.detail.cookie.categories))
window.addEventListener('cc:onChange', (e) => sync(e.detail.cookie.categories))The consent cookie
The visitor's decision is stored in a first-party cookie named cw_consent, URL-encoded JSON:
json
{
"categories": ["necessary", "analytics"],
"consentId": "a1b2c3d4-…",
"revision": 0,
"consentTimestamp": "2026-07-26T10:00:00.000Z",
"lastConsentTimestamp": "2026-07-26T10:00:00.000Z",
"languageCode": "en"
}Read it server-side, or from a tag manager, to branch on consent without listening for an event.
Google Tag Manager
Two ways to fire a non-Google tag on consent:
Custom Event trigger. In GTM, create a Custom Event trigger with the event name cc:onChange (enable regex matching if you also want cc:onConsent). Bind your tag to it. GTM's dataLayer does not receive these by default, so push them yourself in a small bootstrap:
js
window.addEventListener('cc:onConsent', (e) =>
dataLayer.push({ event: 'cc:onConsent', cwCategories: e.detail.cookie.categories }))
window.addEventListener('cc:onChange', (e) =>
dataLayer.push({ event: 'cc:onChange', cwCategories: e.detail.cookie.categories }))1st-party cookie variable. Create a GTM 1st-Party Cookie variable reading cw_consent, and check whether it contains the category you need in your trigger condition.
For Google tags specifically you need neither — turn on the Google Consent Mode toggle and GTM gates them natively.