Consent Docs

Google Consent Mode

What the runtime sends to Google Consent Mode v2 and other ad tags, when it sends it, and how each purpose category maps to a signal.

Concept3 min readFor web, backend and mobile developers

Google tags do not wait for the banner. They load, then read consent from seven Consent Mode v2 signals. The runtime sends those signals for you, from the answer the visitor gave. With the runtime tag first in <head>, there is nothing to code.

How it works#

The runtime sets the defaults as the first thing it does, before it knows who the visitor is. That is why its tag goes first: a Google tag that starts earlier has no defaults to read.

JavaScript
gtag('consent', 'default', {
  ad_storage: 'denied',
  ad_user_data: 'denied',
  ad_personalization: 'denied',
  analytics_storage: 'denied',
  functionality_storage: 'denied',
  personalization_storage: 'denied',
  security_storage: 'granted',
  wait_for_update: 500
});
gtag('set', 'ads_data_redaction', true);

wait_for_update makes Google tags hold their first hit for 500 milliseconds while the visitor's region and choice are resolved. For a returning visitor, the defaults are the choice stored in this browser. The runtime creates window.dataLayer and window.gtag if the page has not.

The runtime then sends gtag('consent', 'update', …) with all seven signals:

  • once it has resolved the visitor's form, with the region's starting state or the recorded answer
  • every time the visitor makes or changes a choice

Each update also sets ads_data_redaction, which is true while ad_storage is denied. Where no form applies to the visitor's region, every signal is granted.

How purposes map to signals#

A purpose sends the signals of its category.

Purpose category Signals
STRICTLY_NECESSARY security_storage
FUNCTIONAL functionality_storage
ANALYTICS analytics_storage
MARKETING ad_storage, ad_user_data, ad_personalization
PERSONALISATION personalization_storage
SALE_OR_SHARING ad_user_data, ad_personalization
SENSITIVE None

The rules:

  • A signal is granted only when every purpose that maps to it is allowed.
  • security_storage is always granted.
  • functionality_storage is granted when the form has no functional purpose to ask about.
  • Any other signal that no purpose maps to is denied.
  • Purposes that are always on are not counted.

An example#

A form has an analytics purpose, a marketing purpose and a sale-or-sharing purpose. The visitor allows analytics and marketing and refuses sale or sharing. The update is:

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

ad_user_data and ad_personalization are denied because one of the purposes behind them was refused.

Who sets the defaults#

Each form has a Google Consent Mode v2 switch in its Settings panel. It is on by default and takes effect when the form is published. The script tag has its own option, data-piedap-google-consent-mode.

You want Do this
No Consent Mode signals at all, because another tool sends them Add data-piedap-google-consent-mode="false" to the tag
Tag Manager to own the defaults Install through the Tag Manager template. It sets the defaults and loads the runtime in update-only mode
Update-only mode without the template Set your own defaults, then add data-piedap-google-consent-mode="update". ads_data_redaction is then yours to set
No updates for one form Switch Google Consent Mode v2 off on the form and publish

Switching the form setting off is not enough on its own

The defaults are set before the runtime knows which form applies, so they are sent even when the form's switch is off. Google tags then never get an update, and a new visitor's signals stay denied. If another tool manages Consent Mode, also set data-piedap-google-consent-mode="false" on the tag.

The template is described in Install with a tag manager or CMS.

Other tags that get the signal#

With each Consent Mode call, the runtime also tells these tags. They follow the same switches.

Tag What is sent
Microsoft Advertising (UET) uetq.push('consent', …) with ad_storage, as a default and at each update
Microsoft Clarity clarity('consentv2', …) with ad_Storage and analytics_Storage
Meta Pixel fbq('consent', 'grant') or fbq('consent', 'revoke'), following ad_storage
TikTok Pixel ttq.holdConsent() at start, then ttq.grantConsent() or ttq.revokeConsent(), following ad_storage

The Microsoft Advertising call is queued on window.uetq for the UET tag to read. The others are sent only when the tag is on the page.

Limits#

  • The mapping follows the category. No setting maps a single purpose to other signals, so choose each purpose's category with the table in mind.
  • Signals follow purposes, not partners. Switching one partner off does not change a signal.
  • Google's tag hosts are not held by automatic blocking. To hold a Google tag until consent instead, add its host to blockedHosts.

↑↓ to move, Enter to open