Skip to main content
CookieBeam
Back to Guides
Integration10 min readBy Armin Zaribaf

Google Tag Manager Integration

Set up CookieBeam in Google Tag Manager using the Community Template Gallery. Covers Consent Mode v2, regional defaults, the load-order trade-off with a direct script tag, and IAB TCF.

Overview

CookieBeam has a template in the Google Tag Manager Community Template Gallery. It sets the Consent Mode defaults, applies a returning visitor's saved choice right away, and loads the CookieBeam banner. It can also forward consent signals to Microsoft Clarity and UET (off by default) and set different defaults by region.

The template doesn't block tags on its own. Consent Mode only governs tags that actually read it, so you'll still need a consent rule on each of your other tags (details below).

What the template does

Google Consent Mode v2

Sets defaults and sends updates for ad_storage, analytics_storage, ad_user_data, ad_personalization and the other consent parameters

Microsoft Consent Mode

Optional, off by default: forwards consent signals to Microsoft UET and Clarity

Regional defaults

Set different default consent states per country or region, covering the moment before the banner loads

Returning visitors

A returning visitor's saved choice is applied immediately, with no wait for the banner

Installation steps

1

Copy your Banner ID

In the CookieBeam dashboard, open your banner and go to Deployment > Install. Choose the Google Tag Manager tab and copy the Banner ID.

2

Add the template from the gallery

In GTM, go to Templates > Search Gallery, search for CookieBeam, and choose CookieBeam Consent Mode. Review the permissions it requests and click Add to workspace.

3

Create the tag

Go to Tags > New > Tag Configuration and pick CookieBeam Consent Mode. Paste your Banner ID. The tag won't load anything without it. Wait for Update defaults to 2000 ms (how long Google tags wait for the consent update); keep it at 500 ms or higher.

4

Set the trigger

Under Triggering, pick Consent Initialization – All Pages and make it the only trigger. This trigger type fires before all others, so the consent default is in place before any other tag runs.

5

Regional defaults (optional)

Expand Regional Consent Defaults to set different default states by country or region; leave the region field blank for the global default. Keep the global default denied unless you have a specific reason to change it. The banner's own regional rules decide what each visitor sees; these defaults only cover the moment before the banner has loaded.

6

Turn on Consent Mode in CookieBeam

In the dashboard, open the banner's App Integrations, turn on Google Consent Mode, click Save Consent Mode Settings, and publish the banner.

7

Preview, save and publish

Use GTM Preview to test a fresh visitor, acceptance, rejection and withdrawal. Check the consent state and the requests your tags send in each scenario. Then submit and publish the container version.

[画像:CookieBeam Install banner page with the Google Tag Manager tab selected, showing three numbered setup steps, a View CookieBeam in the Gallery link, the Banner ID field with a Copy button, a note that GTM loads later than a direct install, and an expandable Container-import fallback section with a download link]
Step 1: open Deployment > Install, choose the Google Tag Manager tab, and copy your Banner ID. The container-file download at the bottom is a fallback.
[画像:Google Tag Manager Templates page with the sidebar highlighting Templates, showing a Tag Templates section and a Variable Templates section, each with Search Gallery and New buttons]
Step 2: go to Templates in the GTM sidebar and click Search Gallery under Tag Templates.
[画像:CookieBeam Consent Mode tag configuration in GTM showing the Wait for Update field set to 2000 milliseconds, collapsible sections for Regional Consent Defaults, Google Consent Mode and Microsoft Consent Mode, the Banner ID field with a UUID-format tooltip, and the Consent Initialization – All Pages firing trigger at the bottom]
Steps 3 and 4: the finished tag with Wait for Update, the Regional Consent Defaults, Google and Microsoft Consent Mode sections, the Banner ID, and the Consent Initialization – All Pages trigger.

Google requires Consent Mode signals, including ad_user_data and ad_personalization, for advertising features with visitors in the EEA and UK. See Google's EU user consent policy and the Consent Mode documentation. The template sends both the defaults and the updates. Google tags that read Consent Mode, such as GA4 and Google Ads, follow them automatically. Consent Mode can let tags send cookieless requests while consent is denied; it doesn't stop every request.

Without regional overrides, the template's global default starts ad_storage, ad_user_data, ad_personalization, analytics_storage and personalization_storage as denied, and functionality_storage and security_storage as granted. See Google Consent Mode for the full behaviour and the Consent Mode v2 guide for background.

Consent Mode parameters

ParameterCookieBeam categoryPurpose
ad_storageMarketingAdvertising cookies (Google Ads, remarketing)
analytics_storageAnalyticsAnalytics cookies (GA4 measurement)
ad_user_dataMarketingSending user data to Google for advertising
ad_personalizationMarketingPersonalised advertising and remarketing
functionality_storageFunctional (or Preferences, when the banner has no separate Functional category)Storage that supports site functionality
personalization_storagePreferencesPersonalisation features
security_storageNecessaryAlways granted (security features)

Microsoft Consent Mode is off by default. Turn on Microsoft Consent Mode in the tag to forward consent signals to Microsoft UET and Clarity as well. Leave it off if you don't use either. For how each Microsoft product uses the signal, see the Microsoft Consent Mode guide.

Configure your other tags

Every tag that collects data needs its own consent rule. Without one, a tag fires on its trigger regardless of the visitor's choice.

Google tags (GA4, Google Ads, Floodlight)

1

Leave the built-in consent checks on

Google tags check Consent Mode on their own. In each tag, open Advanced Settings > Consent Settings and confirm it still uses the built-in checks.

2

Do not override them

Don't set a Google tag to No additional consent required unless you've made that decision deliberately.

Tags from other vendors

1

Require additional consent

These tags don't read Consent Mode. In Advanced Settings > Consent Settings, choose Require additional consent for tag to fire and pick the matching storage type (ad_storage for an advertising pixel, for example).

2

Or fire from CookieBeam's events

Use the CookieBeam consent events as the trigger instead of All Pages; see GTM data layer events.

Environments and the container-file fallback

The template always loads the version published to production. To test a staging version, use a script tag with the environment loader on your staging site instead. If you can't use the gallery, the install page has a container file you can download; import it with Admin > Import Container > Merge, double-check the Banner ID and trigger, and watch for duplicate consent tags.

Testing your setup

Testing checklist

  • Banner appears on page load

    Open the site in a private window and confirm the banner shows

  • CookieBeam fires on Consent Initialization

    In GTM Preview, check that the CookieBeam tag fires on the first event

  • Defaults match what you set

    The Consent tab should show ad and analytics types denied before a choice; functionality_storage and security_storage start granted unless you changed them

  • Consent updates on acceptance and rejection

    Accept in one window, reject in a fresh one, and confirm the Consent tab shows the correct update each time

  • Other tags follow their rules

    Confirm each tag fires or stays blocked as expected, and check the requests in the browser's Network panel

  • The choice persists

    Reload the page and confirm the choice is still remembered

IAB TCF with GTM

IAB TCF is an optional second consent layer for publishers whose ad partners ask for a TC string. Most sites don't need it. It's a setting on the banner, not on the GTM tag, and it works alongside Consent Mode: Google tags keep following the Consent Mode signals, while TCF adds the __tcfapi interface and a vendor list for TCF-participating vendors. CookieBeam is a registered CMP in IAB Europe's TCF (CMP ID 526); registration is separate from compliance, and TCF here covers the web only.

Turn on TCF

1

Check your plan

TCF is part of the IAB TCF and GPP feature, available on Professional plans and above.

2

Open the Frameworks section

In the dashboard, open the banner, go to the Consent tab, and find the Frameworks section under Consent frameworks.

3

Turn it on

Enable Use IAB TCF v2.4 for this banner, enter the Publisher country code, and choose your vendors. If you serve Google ads, include Google Advertising Products (vendor 755). Google Additional Consent is a separate toggle in the same card.

4

Save and publish

Click Save TCF settings, then publish the banner. Settings take effect only after publishing.

[画像:CookieBeam dashboard showing the IAB Transparency and Consent Framework (TCF v2.4) card with a description of what TCF does, the Use IAB TCF v2.4 for this banner toggle (off), the Apply TCF to all visitors toggle (off), and the Publisher country code field]
The TCF card under Consent > Frameworks. Turn on Use IAB TCF v2.4 for this banner and enter your publisher country code. The vendor list, Google Additional Consent toggle and Save TCF settings button are further down the same card.

Two things to keep in mind when loading CookieBeam through GTM with TCF on. First, the __tcfapi stub only exists after the CookieBeam tag has fired, so an ad tag that runs earlier won't find it. With a script tag above your ad tags the stub is there from the start. If TCF matters for your ad stack, prefer the script tag. Second, for personalised ads to visitors in the EEA, the UK and Switzerland, Google AdSense, Ad Manager and AdMob require a CMP from Google's own certification programme, which is separate from IAB registration. CookieBeam is a Google-certified CMP for web; see the TCF setup docs and Google's publisher requirements. Background: What is TCF, TCF for publishers, TCF vs Consent Mode v2 and Google Additional Consent.

Troubleshooting

Banner not showing?

  • Check that the CookieBeam tag fires in GTM Preview
  • Verify the Banner ID: it's a UUID shown on Deployment > Install; copy it rather than typing it
  • The template loads the version published to production, so make sure the banner is published
  • Check the browser console for JavaScript errors

Tags firing without consent?

  • Confirm the CookieBeam tag uses Consent Initialization – All Pages, not All Pages
  • Check that each non-Google tag has a consent rule in Advanced Settings
  • Keep in mind that Google tags can send cookieless requests while consent is denied
  • Scripts hard-coded in the page aren't managed by GTM: mark them type="text/plain" with data-category, see script blocking

Consent Mode not working in GA4?

  • Turn on Google Consent Mode under the banner's App Integrations and publish
  • Confirm Google Consent Mode is on in the tag
  • Run window.CookieBeamGTM?.getConsent() and inspect window.dataLayer before and after a choice

Frequently asked questions

Should I install through GTM or with a script tag?

Use a script tag in <head> if you can edit the page: it starts before GTM and can hold back every tag GTM loads. GTM is for when you don't have that option.

Does the template block my tags?

No. It sets the Consent Mode defaults and updates. Google tags follow them; other tags need their own consent rules.

Which trigger should the CookieBeam tag use?

Consent Initialization – All Pages, and only that trigger.

Can I test a staging banner through GTM?

No. The template always loads the production version. Use a script tag with the environment loader on your staging site instead.

Do I need TCF?

Only if your ad partners ask for a TCF consent string. It's a banner setting on Professional plans and above, not part of the GTM tag.

5 min read

Pinterest, Snapchat & Reddit Pixels: Consent Gating

The smaller ad pixels don't ship a Google-style consent mode, so the safe default is the same for all three: don't load until the visitor accepts marketing. Here's the pattern for Pinterest, Snapchat, and Reddit, browser and server.

6 min read

Meta Pixel & Conversions API: Consent Gating Done Right

Meta Consent Mode gives you fbq('consent','grant') and fbq('consent','revoke'), but the Conversions API ignores them. Here's the full consent layer for Meta: browser pixel, server events, US opt-outs, and withdrawal.

6 min read

LinkedIn Insight Tag & Consent: Gate It Right

The LinkedIn Insight Tag has no consent switch of its own, so B2B teams lean on legitimate interest and skip the banner. That's the wrong call. Here's how to load the tag only after consent, browser side and via the Conversions API.

5 min read

TikTok Pixel & Events API: Load It Only After Consent

The default TikTok Pixel snippet writes cookies the moment it loads, before anyone touches your banner. Here's how to gate both the browser pixel and the Events API on real consent, using TikTok's Cookie Consent Mode.

AltStyle によって変換されたページ (->オリジナル) /