Documentation › Implementation › Google Tag Manager

How to install the cookie bar through Google Tag Manager

You add the official Cookies správně template from the gallery to your container, enter your license key in it and fire it with the Consent Initialization trigger. GTM then controls the other tags according to the consent given. This is the recommended installation method.

When to choose this method

When you already manage measurement in Google Tag Manager and want to control consent centrally. Compared with inserting the script directly into the code, debugging and versioning are easier, and in GTM you choose for yourself between basic and advanced mode of Google Consent Mode.

What you will need

  • Google Tag Manager already installed on the website.
  • Access to GTM with permission to publish.
  • The license key for the domain. You will find it in the dashboard on the license's Overview tab.
  • Google Tag Manager selected as the Implementation type in the license Configuration. The bar then does not set the Consent Mode default itself; the template sets it.
  • We recommend turning on Consent Overview in Admin → Container Settings.

Screen names are given as they appear in the English GTM interface.

1. Adding the template from the gallery

In GTM go to Templates → Tag Templates → Search Gallery, search for Cookies správně and add the template to your workspace.

2. Configuring the tag

Create a new tag and choose the Cookies správně template. Fill in these fields:

FieldWhat goes in it
License keyThe key for the domain from the dashboard.
LanguageAn empty field means automatic selection based on the visitor's browser. If you choose a specific language, the bar always runs in it.
wait_for_updateHow long Google tags wait for a consent update before they send data. The default is 500 ms.
Ads RedactionSets ads_data_redaction. When ad_storage is denied, ad click identifiers are removed from Google Ads and Floodlight tag requests. Off by default.
URL Pass ThroughSets url_passthrough. When cookies are denied, information about ad clicks is passed between pages in URL parameters. Off by default.
Default consent by regionOptional. Each row sets the default consent state for the listed regions (ISO 3166-1 or ISO 3166-2 codes, for example US, CA or US-CA). In all other regions denied applies. The visitor's choice in the bar always takes precedence.

The exact meaning of each field according to Google's documentation is on the Consent Mode settings and signals page.

3. Firing the tag

Fire the Cookies správně tag with the Consent Initialization – All Pages trigger. This is essential: it makes the bar run as the very first tag in the whole container, so the default consent state is set before any other tag fires.

If you use the ordinary All Pages trigger, some tags may fire before the template sets the consent defaults.

4. Configuring the other tags

Google tags

GA4, Google Ads and other Google tags have built-in consent checks: GA4 follows analytics_storage, Google Ads follows ad_storage and, depending on the setup, ad_user_data and ad_personalization. How to fire them depends on which Consent Mode you want:

  • Advanced mode: leave No additional consent required in Consent Settings and fire them with the ordinary All Pages trigger. They load straight away and work with denied values until consent is given.
  • Basic mode: in Consent Settings choose Require additional consent with the consent types the tag needs, and fire them with the Custom Event trigger consentUpdate. They do not fire at all until consent is given.

The difference between the modes according to Google and both setups are described in detail on the Basic and advanced mode page.

Other tags

For custom HTML, Meta, LinkedIn, Hotjar, Microsoft Clarity or Sklik, open Consent Settings, choose Require additional consent and select the consent types the service needs. You have to work out yourself what purpose the service serves and which consent type matches it.

Fire these tags with a Custom Event trigger with the event name consentUpdate. You create it in Triggers → New → Custom Event. The bar sends this event:

  • when the visitor clicks in the bar,
  • again on every page when a visitor returns with their consent stored in the cc_cookie cookie.

The tag therefore fires once per page, and only when consent exists. Its Consent Settings make sure it does not fire when consent is denied.

Do not fire these tags on the gtm_consent_update event. The template sends it only to a returning visitor when the page loads, not after a click in the bar. The All Pages trigger alone is not enough either: the tag will then not fire for a new visitor at the moment they give consent.

5. Testing

Starting the preview

In GTM open Preview and enter the website address. Once connected, the website opens and Tag Assistant shows the Connected status and the Event Timeline, typically with the gtm.init, gtm.js and consent_default events.

Before consent is given

On the Consent tab, check in the On-page Default column that the default values are denied for ad_storage, analytics_storage, functionality_storage, personalization_storage, ad_user_data and ad_personalization. The exception is security_storage, whose default is granted.

On the Tags tab, tags that require additional consent must be Not Fired.

After consent is given

Click Accept all or save a specific combination of categories. The consentUpdate event must appear in the Event Timeline and the relevant values in the On-page Update column switch to granted. Categories the visitor left off stay denied and their tags remain blocked.

On the second visit

Close the preview, open the website again and start the preview a second time without deleting cookies. The bar no longer appears because your choice is stored. The template passes the stored consent state as soon as the page loads; in the Event Timeline you will see gtm_consent_update and, once the bar has loaded, consentUpdate, and the tags you consented to must fire.

Migrating from the old implementation?

If your GTM still contains the original Cookies správně HTML tags, first go through the migration to the new template. Old and new tags must not run side by side.