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.
How Consent Mode works with Cookiebot
Section titled “How Consent Mode works with Cookiebot”- Default state (set before GTM loads): All consent signals start as
denied - Cookiebot banner loads: User sees the cookie consent banner
- User accepts/declines: Cookiebot updates the consent state
- Google tags adjust: With
analytics_storage: denied, GA4 sends cookieless pings and models conversions. Withanalytics_storage: granted, full tracking resumes.
Step 1 — Install the Cookiebot GTM template
Section titled “Step 1 — Install the Cookiebot GTM template”-
In GTM → Templates → Tag Templates → Search Gallery
-
Search for Cookiebot → select the official Cookiebot CMP template by Cybot
-
Click Add to workspace
-
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)
- Tag name:
-
Set tag priority to 10 or higher to ensure it fires before other tags
Step 2 — Set default consent state
Section titled “Step 2 — Set default consent state”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 -->Step 3 — Cookiebot consent category mapping
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 Category | Google Consent Signal |
|---|---|
| Statistics | analytics_storage |
| Marketing | ad_storage, ad_user_data, ad_personalization |
| Preferences | functionality_storage, personalization_storage |
| Necessary | Always granted — no mapping needed |
The Cookiebot GTM template fires gtag('consent', 'update', {...}) when the user interacts with the banner or changes their preferences.
Step 4 — Configure GA4 and Google Ads tags for Consent Mode
Section titled “Step 4 — Configure GA4 and Google Ads tags for Consent Mode”-
Open your Google Tag in GTM
-
Click Advanced Settings → Consent Settings
-
Verify the Additional consent checks required is set to use the built-in consent checks
-
For the Google Ads Conversion Tracking tag:
- Advanced Settings → Consent Settings
- Set: Require additional consent for
ad_storageandad_user_data
-
Publish the container
-
In Google Ads → Tools → Consent → Consent Mode, verify the tag is detected as “Active”
Verification
Section titled “Verification”In GTM Preview Mode
Section titled “In GTM Preview Mode”- Open GTM Preview and visit your site
- The Cookiebot banner should appear
- In the Summary pane, the
CMP - Cookiebottag should fire under the Consent section (or as the first tag) - Without interacting with the banner, check the dataLayer panel — consent signals should show
denied - Accept all cookies
- The consent update event should appear in the Summary pane
- Check the Variables tab —
analytics_storageshould now showgranted
In GA4 DebugView
Section titled “In GA4 DebugView”- Visit your site with the debug view active
- Accept cookies
- Navigate around the site
- Events should appear in DebugView — GA4 was sending cookieless pings before consent, and now sends full events
Checking the consent state programmatically
Section titled “Checking the consent state programmatically”// In browser console — check current consent state// Requires Cookiebot to be loadedconsole.log('Statistics:', Cookiebot.consent.statistics);console.log('Marketing:', Cookiebot.consent.marketing);console.log('Preferences:', Cookiebot.consent.preferences);Advanced Consent Mode vs. Basic Consent Mode
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.
Test it
Section titled “Test it”- Clear all cookies and visit your site in a private window
- Verify the Cookiebot banner appears
- Open browser DevTools → Application → Cookies — no
_gaor ad cookies should be present - Accept all cookies
- Check Cookies again —
_gaand other cookies should now be set - Navigate between pages — GA4 events should appear in DebugView with full session data
Common gotchas
Section titled “Common gotchas”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.