Skip to main content
Back to Guides
Integration5 min read

Google Tag Manager Integration

Complete guide to integrating CookieBeam with Google Tag Manager using the official GTM template. Includes Consent Mode v2, Microsoft Clarity, and regional defaults.

Overview

CookieBeam provides an official Google Tag Manager template that handles all consent management automatically. This template supports Google Consent Mode v2, Microsoft Consent Mode (Clarity & UET), and regional consent defaults.

Template Features

Google Consent Mode v2

Full support for ad_storage, analytics_storage, ad_user_data, ad_personalization

Microsoft Consent Mode

Native support for Microsoft Clarity and UET consent signals

Regional Defaults

Configure different defaults for EEA, UK, US, and other regions

Zero Dependencies

High-performance CDN loading with no external dependencies

Download the Template

While we await GTM Gallery approval, you can download the template directly from GitHub: github.com/cookiebeam/cookiebeam-gtm. Import the template.tpl file into GTM via Templates > New > Import.

Installation Steps

1

Get Your Banner ID

Log in to your CookieBeam dashboard, select your banner, and go to the Installation tab. Copy your Banner ID (format: abc123-def456-ghi789).

2

Import the Template

In GTM, go to Templates > Tag Templates > New. Click the three dots menu and select "Import". Upload the template.tpl file from the GitHub repository, or search for "CookieBeam" in the Community Template Gallery once approved.

3

Create the Tag

Go to Tags > New. Select "CookieBeam Consent Mode" as the tag type. Enter your Banner ID in the configuration field.

4

Set the Trigger

Click "Triggering" and select "Consent Initialization - All Pages". This ensures CookieBeam loads before any other tags, which is required for GDPR compliance.

5

Configure Regional Defaults (Optional)

Expand "Regional Settings" in the tag configuration. Set different consent defaults for EEA (denied by default for GDPR), US (granted by default for opt-out model), or other regions as needed.

6

Save and Publish

Save the tag, then click "Submit" to publish your container. Add a version name like "Add CookieBeam Consent" and click "Publish".

CookieBeam dashboard Deployment screen showing the Banner ID, a Download GTM Template button, and Quick Setup steps
Step 1, Find your Banner ID (and a one-click template download) on the dashboard's Deployment screen.
Google Tag Manager Templates screen with Tag Templates and Variable Templates sections and the New and Search Gallery buttons
Step 2, In GTM open Templates → New to import template.tpl (or Search Gallery once the template is approved).
GTM tag configuration for the CookieBeam Consent Mode tag: Wait for Update, Regional and Google and Microsoft Consent Mode sections, the Banner ID field, and a Consent Initialization - All Pages trigger
Steps 3–4, Configure the CookieBeam Consent Mode tag with your Banner ID, then trigger it on “Consent Initialization – All Pages.”

Google Consent Mode v2

Google Consent Mode v2 is required for EU compliance since March 2024. CookieBeam automatically signals consent states to Google Analytics 4 and Google Ads.

Consent Mode Parameters

ad_storage
analytics_storage
ad_user_data
ad_personalization
functionality_storage
personalization_storage
security_storage

Microsoft Consent Mode (Clarity & UET)

CookieBeam also supports Microsoft Consent Mode for Clarity session recordings and UET (Universal Event Tracking) for Microsoft Ads. The template automatically sends consent signals to both platforms.

Microsoft Clarity

Clarity respects the Analytics consent category. When users grant analytics consent, Clarity will record sessions. When denied, Clarity enters a privacy-safe mode. No additional configuration needed - the CookieBeam template handles this automatically.

Microsoft UET (Bing Ads)

Microsoft UET for Bing Ads respects the Marketing consent category. Conversion tracking and remarketing only activate when users grant marketing consent. The template sends the appropriate consent signals to the Microsoft advertising platform.

Configure Your Existing Tags

After installing CookieBeam, update your existing Google and Microsoft tags to respect consent settings.

Update Google Analytics 4 Tags

1

Open your GA4 Configuration tag

In GTM, find your Google Analytics 4 Configuration tag and click to edit it.

2

Enable Consent Settings

Expand "Advanced Settings" > "Consent Settings". Check "Require additional consent for tag to fire" and select "analytics_storage".

Update Google Ads Tags

1

Open your Google Ads tags

Edit each Google Ads Conversion Tracking and Remarketing tag.

2

Enable Consent Settings

In "Advanced Settings" > "Consent Settings", check the consent requirement box and select both "ad_storage" and "analytics_storage".

Important: Tag Firing Order

The CookieBeam tag MUST fire before any other marketing or analytics tags. Always use the "Consent Initialization - All Pages" trigger for CookieBeam. This ensures consent defaults are set before other tags attempt to fire.

Testing Your Setup

Testing Checklist

  • Banner appears on page load

    Visit your website and verify the consent banner displays

  • Consent Initialization fires first

    In GTM Preview, check that CookieBeam fires on "Consent Initialization"

  • Default consent is "denied"

    Check the Consent tab in GTM Preview shows denied states before interaction

  • Consent updates on acceptance

    Accept cookies and verify consent states change to "granted"

  • GA4 respects consent

    Verify GA4 only fires after analytics consent is granted

  • Preferences persist

    Reload the page and verify your consent choice is remembered

Troubleshooting

Banner not showing?

  • Check that the CookieBeam tag is firing in GTM Preview mode
  • Verify your Banner ID is correct (no typos)
  • Clear your browser cache and cookies, then reload
  • Check browser console for JavaScript errors

Tags firing without consent?

  • Ensure CookieBeam uses "Consent Initialization" trigger (not "All Pages")
  • Verify other tags have consent requirements configured in Advanced Settings
  • Check that no tags are set to fire on "Consent Initialization" except CookieBeam

Consent Mode not working in GA4?

  • Enable Consent Mode v2 in your CookieBeam dashboard under Banner Settings
  • Check GA4 Realtime report for consent signals
  • Verify GA4 property has Consent Mode enabled in Admin > Data Streams > Consent settings

Need Help?

If you're still having issues, contact us at [email protected] or visit our troubleshooting page. Our team is happy to help you get set up correctly.