Google Tag Manager

Keep your container. The banner sets Google Consent Mode before GTM loads, so Google's tags adjust by themselves, and the rest wait for the category they need.

What happens on every page

  1. The banner script runs first and sets Consent Mode defaults for the visitor's region: denied wherever the visitor must be asked first, unless you chose otherwise in Settings.
  2. A returning visitor's choice is applied as the default straight away, then sent once more as an update, still before GTM. Tag Assistant shows their choice, and nothing fires twice.
  3. Microsoft UET (Bing Ads) gets the same consent signal.
  4. GTM loads. When the visitor chooses, the banner sends a Consent Mode update and pushes events to the dataLayer.

Categories and Consent Mode

CategoryConsent Mode signals
Necessarysecurity_storage
Functionalfunctionality_storage
Preferencespersonalization_storage
Statisticsanalytics_storage
Marketingad_storage, ad_user_data, ad_personalization

Tags that are not Google's

Meta, TikTok, LinkedIn and other pixels do not read Consent Mode. Fire them on a custom event trigger for the category they need, which the banner pushes the moment a visitor allows it:

EventWhen
consent_marketing_updateMarketing was just allowed
consent_measurement_updateStatistics was just allowed
consent_experience_updatePreferences was just allowed
consent_functionality_updateFunctional was just allowed
consent_updateAny change, and on every page where a choice already exists

On later pages a returning visitor's choice is already in place before GTM starts, so use Consent Mode's built-in checks (Additional consent checks on the tag) or a trigger on consent_update with a condition on the category. The per-category events fire only when a category is newly allowed, never on page load, so a tag never fires twice.

Or let the banner load common pixels itself after consent, without GTM: Tracking → Blocking and tags in the dashboard (Meta, TikTok, Microsoft UET, Clarity).

Installing through GTM instead

If you cannot edit the page's <head>, add the banner through GTM, as with Cookiebot: the Trackable CMP tag template on the Consent Initialization - All Pages trigger. In the dashboard, Install → Add to Google Tag Manager puts the template, tag, triggers and variables into a new workspace of your container. Nothing is published until you publish it.

The tag sets the same defaults (your region table is copied into it) and then loads the banner. GTM must be the first script on the page for this to work.

GTM does not let templates read the browser's opt-out signal (Global Privacy Control), so in US regions the tag starts analytics and marketing as denied. The banner reads the signal a moment later and allows them for visitors who do not send it.

Letting the banner load GTM

The banner can load your container itself, so it always comes after the consent defaults: in the dashboard, Tracking → Google Tag Manager → Container ID. Then remove your own GTM snippet; the banner script stays as it is.

The Loader URL next to it loads GTM from a server-side tagging loader (a Stape custom loader) or a Google tag gateway path on your site, instead of from Google. Events and the JavaScript API: For developers.

Next: Domains and verification