Skip to content

Consent Mode v2 with Cookiebot

Google Consent Mode v2 requires four consent signals: ad_storage, analytics_storage, ad_user_data, and ad_personalization. Cookiebot maps its consent categories to these signals. This recipe covers the complete GTM-based integration using Cookiebot’s official GTM template.

  1. Default state (set before GTM loads): All consent signals start as denied
  2. Cookiebot banner loads: User sees the cookie consent banner
  3. User accepts/declines: Cookiebot updates the consent state
  4. Google tags adjust: With analytics_storage: denied, GA4 sends cookieless pings and models conversions. With analytics_storage: granted, full tracking resumes.

Step 1 — Install the Cookiebot GTM template

Section titled “Step 1 — Install the Cookiebot GTM template”
  1. In GTM → Templates → Tag Templates → Search Gallery

  2. Search for Cookiebot → select the official Cookiebot CMP template by Cybot

  3. Click Add to workspace

  4. Create a new tag from the Cookiebot template:

    • Tag name: CMP - Cookiebot
    • Template: Cookiebot CMP
    • Cookiebot ID: your Cookiebot domain group ID (from your Cookiebot account)
    • Mode: Automatic (recommended)
    • Trigger: Consent Initialization - All Pages (or All Pages if Consent Initialization is not available in your GTM version)
  5. Set tag priority to 10 or higher to ensure it fires before other tags

This is the critical step. The default consent state must be denied for all signals until the user actively accepts.

Add this code to your website before the GTM snippet in <head>:

<!-- Google Consent Mode v2 defaults — MUST be before GTM snippet -->
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
// Set all signals to denied 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', // Always grant security cookies
wait_for_update: 500 // Wait 500ms for CMP to update before sending
});
</script>
<!-- GTM snippet follows here -->
Section titled “Step 3 — Cookiebot consent category mapping”

Cookiebot uses its own category names. The GTM template automatically maps them to Google Consent Mode signals:

Cookiebot CategoryGoogle Consent Signal
Statisticsanalytics_storage
Marketingad_storage, ad_user_data, ad_personalization
Preferencesfunctionality_storage, personalization_storage
NecessaryAlways granted — no mapping needed

The Cookiebot GTM template fires gtag('consent', 'update', {...}) when the user interacts with the banner or changes their preferences.

Section titled “Step 4 — Configure GA4 and Google Ads tags for Consent Mode”
  1. Open your Google Tag in GTM

  2. Click Advanced Settings → Consent Settings

  3. Verify the Additional consent checks required is set to use the built-in consent checks

  4. For the Google Ads Conversion Tracking tag:

    • Advanced Settings → Consent Settings
    • Set: Require additional consent for ad_storage and ad_user_data
  5. Publish the container

  6. In Google Ads → Tools → Consent → Consent Mode, verify the tag is detected as “Active”

  1. Open GTM Preview and visit your site
  2. The Cookiebot banner should appear
  3. In the Summary pane, the CMP - Cookiebot tag should fire under the Consent section (or as the first tag)
  4. Without interacting with the banner, check the dataLayer panel — consent signals should show denied
  5. Accept all cookies
  6. The consent update event should appear in the Summary pane
  7. Check the Variables tab — analytics_storage should now show granted
  1. Visit your site with the debug view active
  2. Accept cookies
  3. Navigate around the site
  4. Events should appear in DebugView — GA4 was sending cookieless pings before consent, and now sends full events
Section titled “Checking the consent state programmatically”
// In browser console — check current consent state
// Requires Cookiebot to be loaded
console.log('Statistics:', Cookiebot.consent.statistics);
console.log('Marketing:', Cookiebot.consent.marketing);
console.log('Preferences:', Cookiebot.consent.preferences);
Section titled “Advanced Consent Mode vs. Basic Consent Mode”

Advanced Consent Mode (recommended): GA4 sends cookieless pings even when consent is denied. Google can model conversions using aggregated, anonymised data. You get behavioral modeling in Google Ads and GA4 reports even for non-consenting users.

Basic Consent Mode: GA4 tags do not fire at all when consent is denied. No modeling data. Simpler but you lose more data.

The Cookiebot template uses Advanced Consent Mode by default (tags fire but operate in cookieless mode when signals are denied). This is the correct choice for most European and UK deployments.

  1. Clear all cookies and visit your site in a private window
  2. Verify the Cookiebot banner appears
  3. Open browser DevTools → Application → Cookies — no _ga or ad cookies should be present
  4. Accept all cookies
  5. Check Cookies again — _ga and other cookies should now be set
  6. Navigate between pages — GA4 events should appear in DebugView with full session data

Banner is not showing. Verify the Cookiebot domain group ID in the GTM template is correct. Check the browser console for Cookiebot errors. Verify the Cookiebot script is not blocked by another script or consent tool.

Consent defaults are not set before GTM. If you see _ga cookies being set before the user accepts, your default consent state is not configured correctly. The denied defaults must be set synchronously before GTM’s gtm.js event fires.

Cookiebot banner loads slowly. If the Cookiebot script is slow, users may see the page briefly before the banner appears. Cookiebot’s wait_for_update parameter (500ms in the example above) gives the CMP time to load before tags proceed.