Google Tag Manager: How to Implement Cookie Consent

Google Tag Manager (GTM) provides a powerful way to manage all your website’s tracking and marketing tags in one place. However, with increasing privacy regulations like GDPR, CCPA, and other regional laws, it is essential to ensure that all tags respect user consent choices.

To facilitate compliance, Google introduced the Consent Mode feature in GTM, which integrates seamlessly with cookie consent management platforms. This guide will walk you through the steps to configure GTM to adhere to your website’s cookie consent banner and apply these settings to both Google and non-Google tags.

Cookie consent icon

Understanding Google Tag Manager’s Consent Overview

The Consent Overview in GTM helps website owners monitor and manage consent settings efficiently. It provides an interface to configure default consent settings and check whether tags respect user permissions before firing.

Key Components of GTM Consent Mode

  1. Consent State Variables – These include ad_storage, analytics_storage, functionality_storage, personalisation_storage, and security_storage. They determine how user data is handled. Learn more about Consent Mode on Google’s Developer Guide.
  2. Consent Initialisation Trigger – Ensures that user consent preferences are captured before any tags are executed.
  3. Tag-Specific Consent Settings – Allows you to define the required consent categories for each tag.
  4. Consent Overview Panel – Displays which tags require consent and whether they comply with user preferences.

Steps to Implement Cookie Consent Banner in GTM

Step 1: Enable Consent Mode in Google Tag Manager

  1. Open Google Tag Manager and navigate to your Container.
  2. Go to Admin > Container Settings.
  3. Enable Consent Overview to view the consent requirements for all tags.
  4. For a visual guide, watch this YouTube tutorial on GTM Consent Mode.

Step 2: Configure Consent Initialisation Trigger

To ensure that user consent is obtained before firing any tracking tags:

  1. Click Triggers > New.
  2. Select Trigger Type > Consent Initialisation – All Pages.
  3. Save and assign this trigger to your consent banner script.
  4. Learn more about Consent Initialisation in Google’s Help Centre.

Step 3: Integrate a Cookie Consent Management Platform (CMP)

To comply with privacy regulations, use a CMP such as Cookiebot, OneTrust, or Complianz:

  1. Implement the CMP script in GTM as a Custom HTML Tag.
  2. Assign the Consent Initialisation Trigger to this tag to ensure it loads before other tracking tags.
  3. Read this guide on choosing the right CMP for your website.

Step 4: Configure Default Consent Settings

  1. In GTM, go to Tags.
  2. Click on New Tag > Select Google Analytics: GA4 Configuration (or any other tracking tag).
  3. Under Tag Settings, locate Consent Settings.
  4. Enable Require Additional Consent and select the necessary consent categories (e.g., ad_storage, analytics_storage).
  5. Save and Publish.

Step 5: Apply Consent Mode to Google and Non-Google Tags

To ensure all tags respect user preferences:

  1. For Google Tags (GA4, Google Ads, etc.):
    • Modify tags to use Google’s built-in consent signals.
    • Enable Consent Mode to send granted or denied values dynamically.
  2. For Non-Google Tags (Facebook Pixel, Hotjar, etc.):
    • Use the CMP’s consent state to create conditional triggers.
    • Example: If a user consents to analytics, only then trigger Hotjar.

For a follow along tutorial click the below LovesData YouTube video:

Step 6: Test Your Consent Configuration

  1. Open Google Tag Manager Preview Mode.
  2. Trigger various consent options on your cookie banner.
  3. Check the Tag Assistant Debugger to verify that tags are respecting the consent preferences.
  4. Use this Chrome extension to test Consent Mode.

Step 7: Publish and Monitor

  1. Once validated, Publish the GTM container.
  2. Regularly review GTM’s Consent Overview to ensure compliance.
  3. Update settings whenever privacy laws change.

Helpful Resources

By leveraging Google Tag Manager’s Consent Overview and Consent Mode, you can ensure that your website complies with global privacy regulations while maintaining effective tracking. Integrating GTM with a cookie consent banner ensures that both Google and non-Google tags respect user choices, safeguarding your site from potential legal issues. By following these steps, you can seamlessly integrate consent management within GTM, providing a privacy-first experience for your visitors while still collecting valuable data in a compliant manner.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top