DEV Community

Nayanika Mathur
Nayanika Mathur

Posted on

Managing Cookie Consent in GTM: A Practical Guide to Consent Mode v2

Cookie consent management in Google Tag Manager (GTM) is about more than deciding whether a tag should fire. The timing and sequence of consent signals are equally important.

Google Consent Mode v2 helps websites adjust Google tag behavior based on a visitor's consent state. A correct implementation can protect privacy while preserving measurement when users provide permission.

Why does consent timing matter?

Tracking scripts can execute before a visitor interacts with a consent banner. If consent is not configured before those scripts run, data may be collected before permission is provided.

On the other hand, overly restrictive configurations can prevent tags from firing even after a user grants consent, resulting in missing analytics and attribution data. (brillmark.com)

Set the consent default first

The consent default should be established before analytics and advertising tags load.

A common configuration starts relevant consent types as denied, including:

  • analytics_storage
  • ad_storage
  • ad_user_data
  • ad_personalization

The wait_for_update parameter can give the Consent Management Platform (CMP) time to provide the user's consent decision before tags proceed based on the default state. (brillmark.com)

Use regional consent settings

Consent requirements can differ by location. Consent Mode allows different defaults to be applied to specific regions.

Regional configurations should be tested carefully because incorrect region codes or outdated rules can cause visitors to receive the wrong consent behavior. Regular geo-testing is therefore an important part of consent QA. (brillmark.com)

Update consent after user interaction

When a visitor accepts, rejects, or changes their consent preferences, the CMP should send an updated consent state.

The update should cover both granted and denied choices. This allows GTM to reassess tags that were previously held back and creates a clearer record of the user's decision. (brillmark.com)

Common Consent Mode mistakes

Watch for these implementation problems:

  • Consent defaults loading too late
  • Missing wait_for_update
  • Incorrect regional configuration
  • The CMP itself being blocked by consent checks
  • No explicit update after rejection
  • Consent state not being passed to server-side GTM
  • Regional rules not being reviewed regularly
  • Insufficient testing across geographic locations

These issues can exist even when the website appears to work normally. (brillmark.com)

Final takeaway

A reliable Consent Mode v2 implementation requires correct sequencing, regional configuration, consent updates, and continuous QA.

The goal is to prevent tracking before consent while allowing permitted measurement to resume when users provide consent.

Read the complete guide:
https://www.brillmark.com/managing-cookie-consent-in-gtm-getting-consent-mode-v2-right/

Top comments (0)