Skip to documentation content

Google Consent Mode v2

How CookieBeam translates category-level consent into Google's 7 Consent Mode v2 keys, including the default-then-update flow, waitForUpdate, ad data redaction, and URL passthrough.

Last updated:

Google Consent Mode is a tag-behavior API. Instead of blocking tags outright, it tells Google tags (Analytics, Ads, Floodlight, GTM) how much data they're allowed to collect. Tags still load, but they adjust their behavior based on the consent state CookieBeam sends them.

CookieBeam handles the integration automatically: it fires the right gtag('consent', ...) calls at the right time, mapping your category-level consent into the 7 keys Google expects. You don't write any Consent Mode code yourself.

The 7 keys

Consent Mode v2 uses 7 boolean keys. Each is either granted or denied.

KeyControls
ad_storageWhether Google can write and read advertising cookies (e.g., _gcl_* for conversion tracking)
ad_user_dataWhether user data can be sent to Google for advertising purposes
ad_personalizationWhether ads can be personalized for this user
analytics_storageWhether Google Analytics can write and read its cookies (e.g., _ga, _gid)
functionality_storageWhether cookies that support site functionality can be stored (e.g., language preferences)
personalization_storageWhether cookies related to personalization can be stored (e.g., video recommendations)
security_storageWhether security-related cookies can be stored (e.g., authentication, fraud prevention). Always granted

Category mapping

CookieBeam maps your consent categories to Consent Mode keys:

CategoryConsent Mode keys
necessarysecurity_storage (always granted)
analyticsanalytics_storage
marketingad_storage, ad_user_data, ad_personalization
preferencesfunctionality_storage, personalization_storage

When a visitor accepts a category, every key it maps to becomes granted. When they reject it or haven't chosen yet, those keys stay denied. The mapping is fixed in the runtime and can't be changed per banner.

The default-then-update flow

Consent Mode works in two steps:

1. Default

On page load, before the visitor has interacted with the banner, CookieBeam fires:

gtag('consent', 'default', {
  ad_storage: 'denied',
  ad_user_data: 'denied',
  ad_personalization: 'denied',
  analytics_storage: 'denied',
  functionality_storage: 'granted',
  personalization_storage: 'denied',
  security_storage: 'granted',
  wait_for_update: 2000
});

This tells every Google tag: "start with nothing granted except security and functionality, and wait up to 2000 ms for a consent decision before firing." The exact denied/granted values depend on the visitor's region (see Regional defaults below) and any existing consent cookie.

CookieBeam fires this call when setDefaultsOnLoad is true (the default).

CookieBeam sets the only Consent Mode default on the page. Whether you install with the script tag or the GTM template, the default is handled for you. Adding a second default, either through a duplicate install or a hand-written gtag('consent', 'default', ...) call, can give Google tags an incorrect consent state before the banner loads. Use one install method and remove any other default.

2. Update

When the visitor makes a choice, or when CookieBeam reads a valid consent cookie from a previous visit, it fires:

gtag('consent', 'update', {
  ad_storage: 'granted',
  ad_user_data: 'granted',
  ad_personalization: 'granted',
  analytics_storage: 'granted',
  functionality_storage: 'denied',
  personalization_storage: 'denied',
  security_storage: 'granted'
});

Tags that were waiting for the update now fire with the correct consent state. Tags that already fired adjust on the next page view.

waitForUpdate

waitForUpdate is the number of milliseconds Google tags wait for a consent update before firing with the default state. If the visitor has a cookie from a previous visit, CookieBeam reads it and fires the update almost immediately, well within the window. If they're new, tags fire after the timeout with all non-essential keys denied.

Set this in Banner settings > Google Consent Mode > Wait for update. The default is 2000 ms. If set to 0, tags fire immediately with the default state and don't wait for CookieBeam to read the cookie.

Ad data redaction

When redactAdsData is enabled and ad_storage is denied, Google tags strip ad click identifiers (gclid, dclid) from requests. This prevents any ad-click data from being sent to Google when the visitor hasn't consented to advertising cookies.

Turn it on in Banner settings > Google Consent Mode > Ads data redaction.

URL passthrough

When urlPassthrough is enabled (it's off by default), CookieBeam tells Google tags to carry ad click identifiers (gclid, dclid) in page URLs when a visitor navigates across domains. This preserves cross-domain conversion attribution even when ad_storage is denied, since the identifier travels in the URL rather than in a cookie.

This is useful for sites that span multiple domains (e.g., a marketing site and a checkout on different hosts). Google can still attribute the conversion without writing a third-party cookie.

Regional defaults

Each regional rule can set its own Consent Mode defaults, one value per key. When a visitor from that region loads the page, CookieBeam uses the rule's defaults in the gtag('consent', 'default', ...) call instead of denying everything.

For example, the GDPR preset denies all keys except functionality_storage and security_storage by default (opt-in). The CCPA preset grants all seven keys by default (opt-out). The PIPEDA preset sends no defaults of its own and inherits the base configuration.

The framework presets set these automatically. You can override them per rule in Regional rules > [rule] > Google Consent Mode defaults.

When no rule matches and the fallback applies, its defaults are used instead.

CookieBeam writes a consentMode field into the consent cookie on every explicit choice:

{
  "consentMode": {
    "v": 1,
    "revision": 3,
    "expiresAt": 1747123456000,
    "state": {
      "ad_storage": "granted",
      "ad_user_data": "granted",
      "ad_personalization": "granted",
      "analytics_storage": "granted",
      "functionality_storage": "denied",
      "personalization_storage": "denied",
      "security_storage": "granted"
    }
  }
}

This snapshot exists for the GTM Consent Mode template (gallery v3.6.0 and later). At Consent Initialization, before CookieBeam's runtime has loaded, the template reads the cookie and restores these exact keys. This avoids a window where tags see "denied" and then immediately get an "update" to "granted" from CookieBeam, which would cause a redundant re-fire.

v is the contract version (currently 1). The GTM template skips snapshots whose v is present and not 1, so a future format change won't be misinterpreted by an older template. Records written by core 0.3.62 and earlier don't carry v and are treated as version 1. revision is the banner's consent revision when the record was written. expiresAt is the cookie's expiry as epoch milliseconds (GTM's sandbox has no Date parser, so the template compares it against Date.now()).

The snapshot is written on explicit visitor choices. When Consent Mode is enabled and the banner uses cookie storage (not localStorage only), the runtime also refreshes the snapshot on page load for returning visitors whose stored choice is still valid (preserved timestamps, no new event). The refresh is skipped when the record has no existing snapshot and the banner's consent lifetimes differ across regions, or when another tab has changed the cookie. Machine-written defaults (opt-out auto-grants) don't write it, so the GTM template falls through to CookieBeam's runtime for those visitors.

Deferred machine defaults

deferMachineDefaults is an advanced flag set by the script builder, not something you configure directly. When Consent Mode is on and the banner writes a machine default (opt-out or notice auto-grant at load), this flag tells CookieBeam to mark the record with isPending: true.

Why: the GTM Consent Mode template reads the cookie at Consent Initialization. Without isPending, it would see a machine default that grants ad_storage (because the visitor is in an opt-out region) and restore that as the consent state, even though the visitor hasn't actively chosen. With isPending, the template skips the record and waits for CookieBeam's runtime to announce the consent state through the proper default → update flow.

See The consent record for how isPending interacts with isDefaultState.

Turn it on in Banner settings > Google Consent Mode. The minimum setup is:

  1. Enable Google Consent Mode.
  2. Verify your category-to-key mapping matches your tag setup.
  3. Set a waitForUpdate value (2000 ms is the default).
  4. Publish.

If you use GTM, install the CookieBeam Consent Mode template from the Community Template Gallery. It reads the consent cookie at Consent Initialization for the fastest possible consent restore.