Google Consent Mode v2 and Google Tag Manager
Set up and verify Google Consent Mode v2 with the Veribenim cookie banner, with or without Google Tag Manager.
On this page
Note: This page describes what the current Veribenim banner script and the Veribenim Consent Mode GTM template actually do. Google's own definitions are linked where they are used.
What Consent Mode v2 is
Google Consent Mode lets a website tell Google tags (Google Analytics 4, Google Ads, Floodlight) which kinds of storage and data use the visitor has agreed to. The tags then adjust their behaviour to those consent states. Version 2 adds two consent types for advertising: ad_user_data and ad_personalization.
Veribenim sends these states for you. The banner script sets the defaults as soon as it runs, re-applies a visitor's saved choice on later page loads, and sends an update every time the visitor accepts, rejects, changes or withdraws consent.
How banner categories map to consent types
| Consent type | Veribenim category | Google's description |
|---|---|---|
analytics_storage | Analytics | Storage related to analytics, for example visit duration. |
ad_storage | Marketing | Storage related to advertising. |
ad_user_data | Marketing | Consent for sending user data to Google for online advertising. |
ad_personalization | Marketing | Consent for personalised advertising. |
functionality_storage | Functional | Storage that supports site functionality, for example language settings. |
personalization_storage | Functional | Storage related to personalisation, for example video recommendations. |
security_storage | Always granted | Storage related to security, for example authentication and fraud prevention. |
Note: Signals are derived from each cookie's "Consent signal" field in your Veribenim cookie inventory, not from the category name alone. If a provider is not in your inventory, its signal is never granted, even after "Accept all". Keep the inventory complete.
What the banner script sends
When the script runs it queues the default command below in the dataLayer, before any Google tag that loads after it. ads_data_redaction is always set; url_passthrough is set only if you turn it on for the site (it is off by default).
gtag('consent', 'default', {
'ad_storage': 'denied',
'analytics_storage': 'denied',
'ad_user_data': 'denied',
'ad_personalization': 'denied',
'functionality_storage': 'denied',
'personalization_storage': 'denied',
'security_storage': 'granted',
'wait_for_update': 2000
});
gtag('set', 'ads_data_redaction', true);
// only when URL passthrough is enabled for the site:
gtag('set', 'url_passthrough', true);- Returning visitor with a saved, still-valid choice: right after the default, in the same synchronous run, the script sends gtag('consent', 'update', …) and pushes a vbn_consent_update event with vbn_consent_source: 'restored'.
- Visitor makes or changes a choice: gtag('consent', 'update', …) and a vbn_consent_update event with vbn_consent_source: 'user'.
- The same Google payload is also passed to the GTM template through window.__vbn_gtm_onConsentChange, if the template's Default tag has registered it.
{
event: 'vbn_consent_update',
vbn_consent: {
analytics_storage: 'granted',
ad_storage: 'denied',
ad_user_data: 'denied',
ad_personalization: 'denied',
functionality_storage: 'granted',
personalization_storage: 'granted'
},
vbn_consent_source: 'user' // 'restored' when a saved choice is re-applied on page load
}Installation
Copy your script address from the Veribenim console: select your site, then the Integration page (menu item "Entegrasyon Kodu"). Both paths below use the same script; there is no extra consent code to write.
Script order and async
The consent default is set at the moment the Veribenim script executes. Google tags that run before it run without a default. Put the Veribenim script in the head, before the Google tag or GTM container snippet, and without async. The GTM template's own requirement reads: the banner script must be in head before the GTM container snippet and without async, so it runs first on every page.
The HTML snippet on the Integration page includes async. That is fine for a page with no Google tags. On a page with Google tags, remove async and place the script first.
Path A: without Google Tag Manager (gtag.js)
Keep your existing Google tag as it is and add the Veribenim script above it. Do not add your own gtag('consent', …) calls; the banner script sends default and update.
<head>
<!-- 1. Veribenim first, without async -->
<script src="https://bundles.veribenim.com/yoursite.js"></script>
<!-- 2. Your Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-XXXXXXXXXX');
</script>
</head>The Google Consent Mode v2 bridge is on by default. You can see it under Integration → "Rıza Sinyali Köprüleri" (consent signal bridges). Turn it off only if another source on your site already sends the same consent commands.
Path B: with Google Tag Manager and the Veribenim template
<head>
<!-- 1. Veribenim first, without async -->
<script src="https://bundles.veribenim.com/yoursite.js"></script>
<!-- 2. Google Tag Manager container snippet (unchanged) -->
<script>(function(w,d,s,l,i){ /* ... GTM-XXXXXXX ... */ })(window,document,'script','dataLayer','GTM-XXXXXXX');</script>
</head>- 1. Import the template. Download template.tpl from the veribenim.gtm-template repository on GitHub. In GTM open Templates → Tag Templates → New, open the ⋮ menu, choose Import, select template.tpl and save.
- 2. Default tag (required). Tags → New → tag type "Veribenim Consent Mode", Consent command = Default. Trigger: Consent Initialization - All Pages.
- 3. Update tag (recommended). Tags → New → "Veribenim Consent Mode", Consent command = Update. Trigger: a Custom Event trigger with the event name vbn_consent_update.
- 4. Publish the container, then verify it (see Verification).
Note: If the template is later published in the GTM Community Template Gallery, you will also be able to add it from there; the tags and triggers stay the same.
Template fields
| Field | Meaning |
|---|---|
Consent command | Default: set defaults and listen for the banner. Update: apply vbn_consent from the data layer. |
Default consent settings | One row per region. Region: ISO 3166-2 codes, comma separated (for example TR, DE, US-CA); blank = every region without its own row; the most specific region wins. Granted / Denied: comma-separated consent types. Types you don't list are not set. A type listed in both columns is denied. The default row denies all six types. |
Wait for update | wait_for_update in milliseconds for every default row. Default 500. |
Redact ads data | Sets ads_data_redaction. On by default. The banner script also always sets it. |
Pass ad click information through URLs | Sets url_passthrough. Off by default. Keep it the same as your site's URL passthrough setting. |
- Only the consent types the banner sends are updated; missing keys are never filled in.
- Values other than granted / denied, and unknown consent types, are ignored and logged.
- security_storage is always granted and can never be denied.
- If the banner script is not on the page, the Default tag still sets the defaults and then reports Failed in Preview, so the problem is visible.
- With the template in place you may turn off the banner's own Google Consent Mode bridge to keep a single source. The banner still calls the template and still pushes vbn_consent_update when that bridge is off.
- Not using the template? Your own GTM tags can listen to the vbn_consent_update event and read vbn_consent from the data layer.
Basic and Advanced mode
Choose the mode in the Veribenim console: your site → Integration → "Google Consent Mode" card. The URL passthrough switch is on the same card. Changes apply after your banner file is regenerated; the console tells you this when you save. Which mode is right for your site is a legal assessment; Google supports both.
| Mode | What happens before consent |
|---|---|
advanced | Default for new and existing sites. Google tags load when the page opens. While consent is denied they do not use cookies and send cookieless pings with the consent state. |
basic | The banner script blocks Google tag scripts until the matching consent is given. If the visitor rejects, no data is sent to Google. |
What Basic mode blocks
| Script address contains | Waits for |
|---|---|
googletagmanager.com/gtag/js?id=G- | Analytics |
googletagmanager.com/gtag/js?id=UA- | Analytics |
googletagmanager.com/gtag/js?id=AW- | Marketing |
googletagmanager.com/gtag/js?id=DC- | Marketing |
googletagmanager.com/gtag/js | Analytics or Marketing (ID not known from the address) |
google-analytics.com | Analytics |
googleadservices.com | Marketing |
doubleclick.net | Marketing |
- The GTM container itself (gtm.js) is not blocked, so non-Google tags in the container keep working. Google tags inside the container load gtag.js and the addresses above, so they wait for consent.
- AdSense is not blocked.
- Tags that the browser parses before the Veribenim script cannot be blocked. This is another reason to load the script first.
- In both modes the consent default and updates are sent the same way. The GTM template needs no extra setting for the mode.
Verification
GTM Preview (Tag Assistant debug mode)
- 1. Click Preview, open your site and do not choose anything in the banner yet.
- 2. Select the Consent Initialization event. The Veribenim Default tag shows Succeeded. If it shows Failed, the banner script is missing or loads after GTM (check the order and async).
- 3. Open the Consent tab on that event. On-page Default shows your defaults, for example ad_storage: Denied, security_storage: Granted.
- 4. Accept or reject in the banner. A vbn_consent_update event appears. Its Consent tab shows On-page Update with your choice, and the Data Layer tab shows vbn_consent and vbn_consent_source: "user". The Update tag fired on it.
- 5. Reload the page. vbn_consent_update appears again with vbn_consent_source: "restored". Check that the update appears before the event that fires your page view tags.
- 6. In the browser console (only in Preview) the template's messages start with "Veribenim Consent Mode:".
Tag Assistant on the live site
- Each Google tag's Consent tab lists the default and the updated states.
- Before a choice: ad_storage, analytics_storage, ad_user_data and ad_personalization are Denied. After accepting: Granted.
Browser console: the dataLayer
Open the developer tools console on your site and run the lines below. The first returns every vbn_consent_update event with its vbn_consent and vbn_consent_source. The second lists the consent commands; the default should come first.
// Veribenim consent events
dataLayer.filter(e => e && e.event === 'vbn_consent_update')
// Consent commands (default / update) in the order they were queued
dataLayer.filter(e => e && e[0] === 'consent')Network requests: gcs and gcd
In the Network tab, filter for requests to Google (for example google-analytics.com or googleadservices.com) and look at the query parameters. Google's consent mode documentation (https://developers.google.com/tag-platform/security/concepts/consent-mode) states that consent mode parameters are translated into HTTP request parameters such as dma, gcd and gcs.
| Parameter | What Google documents |
|---|---|
gcs | Transmits the ad_storage and analytics_storage states. |
gcd | Always sent to Google services, whether consent mode is active or not. Encodes detailed information about the user's consent choice through the consent types. |
What to check: the values of gcs and gcd on requests sent after you accept or reject differ from those sent before the choice. Google does not publish a character-by-character key for these values in that document, so this page does not decode them; use Tag Assistant's Consent tab to read the exact states.
Common mistakes
Default tag on the wrong trigger
Symptom: some Google tags fire before any consent state exists. Cause: the Default tag uses All Pages or Initialization, which fire later and race with your other tags. Fix: use Consent Initialization - All Pages for the Default tag.
Script after GTM, or loaded with async
Symptom: the Default tag shows Failed in Preview and the console logs "Veribenim banner script not found. Load it before the GTM container snippet, without async." Without GTM: Google hits leave the page before the consent default. Fix: move the Veribenim script above the Google tag or GTM snippet and remove async.
Old event name veribenim_consent_update
Symptom: the Update tag never fires. Cause: earlier template versions used a Custom Event trigger named veribenim_consent_update, which the banner does not push. Fix: re-import the current template.tpl and change the trigger's event name to vbn_consent_update.
Consent stays denied after Accept all
Cause: the provider's cookies are missing from your cookie inventory, or have no consent signal, so its signal is never granted. Fix: add the provider to the inventory (the cookie scanner helps) and check its "Consent signal" field.
Two sources sending consent
Symptom: consent states change unexpectedly between commands. Cause: another script or your own GTM tags also send gtag('consent', …). Fix: keep a single source. If you manage consent mode in GTM, turn off the banner's Google Consent Mode bridge; the template and the vbn_consent_update event keep working.
Settings change but the site does not
Mode, URL passthrough and bridge switches are built into your banner file. They apply after the file is regenerated, as the console notes when you save.
Other consent signals
The same visitor decision is translated into other platforms' consent APIs. Microsoft UET runs on page load and on every decision. Meta, TikTok and Clarity are signalled when the visitor decides; on later page loads, scripts managed by Veribenim are injected only if consent exists.
| Platform | Signal from Veribenim | Based on |
|---|---|---|
Microsoft UET | uetq consent default (ad_storage: denied) next to the Google default, then consent update with ad_storage. UET has no analytics_storage equivalent. Can be turned off under consent signal bridges. | Marketing |
Meta Pixel | fbq('consent', 'grant') or fbq('consent', 'revoke'). | Marketing |
TikTok Pixel | ttq.enableCookie() or ttq.disableCookie(). | Marketing |
Microsoft Clarity | clarity('consentv2', { ad_Storage, analytics_Storage }). When analytics is denied, clarity('consent', false) is sent first to clear cookies and end the session. | Analytics and Marketing |
window.uetq = window.uetq || [];
window.uetq.push('consent', 'default', { 'ad_storage': 'denied' });
// on page load (saved choice) and on every decision:
window.uetq.push('consent', 'update', { 'ad_storage': 'granted' }); // or 'denied'LinkedIn Insight and Hotjar are also handled on withdrawal. The GTM template only covers Google Consent Mode; the other signals come from the banner script.
Links
- GTM template and README: https://github.com/Pariette-Inc/veribenim.gtm-template
- Google consent mode overview: https://developers.google.com/tag-platform/security/concepts/consent-mode
- Consent mode in GTM templates: https://developers.google.com/tag-platform/tag-manager/templates/consent-apis
- Microsoft Clarity Consent API v2: https://learn.microsoft.com/en-us/clarity/setup-and-installation/clarity-consent-api-v2