LW IT Solutions
« Blog Overview /Digital Analytics/Tutorials / Tutorial: Advanced Implementation of Google Consent Mode...
This post in other languages:

Tutorial: Advanced Implementation of Google Consent Mode v2 via Google Tag Manager

Tutorial: Advanced Implementation of Google Consent Mode v2 via Google Tag Manager
Contents
  1. Step 1: Adding the CMP Template
  2. Step 2: Configuring the Default Consent State
  3. Step 3: Setting Up the Consent Update Mechanism
  4. Step 4: Verifying DataLayer Signals
  5. Step 5: Preventing Session Breakage
  6. Sources

Google Consent Mode v2 (GCM v2) is an essential framework for ensuring legal compliance and enabling accurate data modeling. The following guide details the step-by-step process of configuring an advanced setup using a Consent Management Platform (CMP), verifying DataLayer signals, and mitigating common issues such as session loss.

Step 1: Adding the CMP Template

The implementation begins with importing a CMP template (such as Usercentrics or Cookiebot) from the Community Template Gallery within Google Tag Manager (GTM). This template provides the necessary logic to translate banner interactions into standardized GCM v2 signals.

Diagram for the article: Adding the CMP Template, Configuring the Default Consent State, Setting Up the Consent Update Mechanism …
The sequence from the article in 5 steps: Adding the CMP Template, Configuring the Default Consent State, Setting Up the Consent Update Mechanism, Verifying DataLayer Signals ….

Step 2: Configuring the Default Consent State

It is critical to establish the initial consent state before any other scripts are executed. A new tag must be created using the CMP template to issue a default command. Parameters including ad_storage, analytics_storage, ad_user_data, and ad_personalization should be set to denied. This tag must be fired using the Consent Initialization – All Pages trigger to guarantee it loads before standard pageview events.

Step 3: Setting Up the Consent Update Mechanism

Upon interaction with the consent banner, an update command must be pushed to the DataLayer. The imported CMP template handles this process automatically, altering the status of the respective parameters from denied to granted when consent is provided.

Step 4: Verifying DataLayer Signals

The implementation is verified in GTM Preview Mode. Within the Tag Assistant, navigate to the DataLayer tab and inspect the consent event. After accepting the tracking conditions, the parameters for ad_storage and analytics_storage must explicitly show the value granted. Proper tag execution (e.g., GA4, Google Ads) depends entirely on the correct transmission of these signals.

Step 5: Preventing Session Breakage

A frequent error during implementation is the corruption of session data, often caused by race conditions where analytics tags fire before the default consent state is established. To avoid session loss, the following architectural rules apply:

  • The default consent tag must strictly utilize the “Consent Initialization” trigger, never the standard “Initialization” or “Page View” triggers.
  • In an Advanced Setup, Google tags should not be blocked by custom exception triggers. Instead, the built-in Consent Checks within the tag settings should be utilized. Hard-blocking tags prevents the transmission of anonymous “cookieless pings,” which ruins the data modeling process and fragments sessions.
  • URL Passthrough should be enabled in the Conversion Linker tag. This ensures that click identifiers (like gclid) are preserved in the URL when navigating between pages, even if storage is denied.
Lukas Wojcik

Lukas Wojcik

Systems architect and technology enthusiast specializing in scalable tracking solutions, GMP Stack (GA4 & GTM), and robust backend architectures. Advocate for clean code and privacy-first design.

Get in Touch

Briefly describe your project or inquiry for a tailored response. This site is protected by reCAPTCHA.

2 comments

  1. Lorena Vasquez

    Step five is the part I wish more tutorials carried: hard-blocking a Google tag destroys the modelling that the rest of the setup was built for.

    Which raises a question about the tags that do need blocking. Meta and TikTok have no cookieless mode, so an exception trigger is the only option there. Does mixing both approaches in one container cause the session breakage described here?

    1. Lukas Wojcik Author

      No — the two do not interact. Blocking a Meta tag prevents a Meta request and nothing else; the Google tag continues to fire, send its cookieless ping and keep the session intact.

      The breakage described in step five comes specifically from blocking the Google tag itself, because that removes the only signal the modelling has. Applying the same reflex to a vendor without a restricted mode is not just harmless, it is the correct handling: a tag with nothing to send when consent is missing should not fire at all.

      So the rule is per vendor rather than per container: built-in consent checks where the vendor implements them, an exception trigger where it does not. A mixed container is the normal outcome of that rule, and it is worth writing down which tag is handled which way — otherwise the next person tidies up the inconsistency and reintroduces the problem.

Write a comment

The email address is not published. Required fields are marked with an asterisk.

ALL ARTICLES & CATEGORIES

CCTV

Follow this category by RSS

Cloud & AI

Follow this category by RSS

Data Privacy

All 11 articles in this category Follow this category by RSS

Digital Analytics

All 44 articles in this category Follow this category by RSS

Digital Marketing

All 25 articles in this category Follow this category by RSS

IT & Networks

All 15 articles in this category Follow this category by RSS

Raspberry PI

Follow this category by RSS

Smart Home

All 11 articles in this category Follow this category by RSS

Web Development

Follow this category by RSS

WordPress Plugins & Tricks

Follow this category by RSS