GTM Integration

Google Tag ManagerCookie Consent Integration

Complete GTM cookie consent integration guide. Implement Consent Mode v2, manage tag firing rules, and ensure GDPR compliance with Google Tag Manager.

Why Use GTM for Cookie Consent?

Google Tag Manager provides powerful consent management capabilities

Consent Mode v2

Built-in Consent Mode v2 support for Google Analytics 4, Google Ads, and other Google services.

Tag Firing Control

Granular control over when tags fire based on user consent choices. No more wasted tracking.

Centralized Management

Manage all your tracking tags and consent logic from one central GTM container.

Advanced Analytics

Track consent rates, user behavior, and conversion impact with detailed GTM reporting.

GDPR Compliance

Built-in GDPR compliance features including consent state management and data retention controls.

Cross-Domain Tracking

Maintain consent state across multiple domains and subdomains with GTM's cross-domain capabilities.

Consent Mode v2 Implementation

Google's latest consent framework for privacy-compliant tracking

What is Consent Mode v2?

Consent Mode v2 is Google's framework for handling user consent in Google Analytics, Google Ads, and other Google services:

  • • Automatically adjusts data collection based on consent
  • • Provides modeling for consented data
  • • Required for Google Ads conversion tracking
  • • Supports granular consent categories

Required Consent Types

Consent Mode v2 requires these specific consent types:

  • ad_storage: Advertising cookies
  • analytics_storage: Analytics cookies
  • functionality_storage: Functional cookies
  • personalization_storage: Personalization cookies
  • security_storage: Security cookies

Consent Mode v2 Implementation Code

// Default consent state (denied)
gtag('consent', 'default', {
  'ad_storage': 'denied',
  'analytics_storage': 'denied',
  'functionality_storage': 'denied',
  'personalization_storage': 'denied',
  'security_storage': 'granted' // Usually granted for security
});

// Update consent when user makes choice
gtag('consent', 'update', {
  'ad_storage': 'granted', // User consented to advertising
  'analytics_storage': 'granted' // User consented to analytics
});

GTM Integration Methods

Choose the integration method that works best for your GTM setup

Method 1: Custom HTML Tag

Recommended

Add our cookie consent as a Custom HTML tag in GTM:

  1. Create new Custom HTML tag
  2. Add your generated cookie banner code
  3. Set trigger to "All Pages"
  4. Configure Consent Mode v2 integration
  5. Publish your container
  • Easy to implement and manage
  • Full GTM integration
  • Requires GTM knowledge

Method 2: Consent Mode Template

Advanced

Use GTM's built-in Consent Mode template:

  1. Install Consent Mode template from Gallery
  2. Configure consent categories
  3. Set up consent triggers
  4. Configure tag firing rules
  5. Test and publish
  • Native GTM integration
  • Advanced consent management
  • Complex setup

Method 3: External Consent API

Developer

Integrate with external consent management platform:

  1. Set up external CMP (Consent Management Platform)
  2. Configure GTM consent API
  3. Map consent categories
  4. Set up data layer events
  5. Configure tag firing rules
  • Enterprise-grade solution
  • Advanced consent features
  • Requires technical expertise

Method 4: Custom JavaScript Variable

Flexible

Create custom JavaScript variables for consent state:

  1. Create custom JavaScript variables
  2. Define consent state logic
  3. Configure trigger conditions
  4. Set up tag firing rules
  5. Test consent state changes
  • Maximum flexibility
  • Custom consent logic
  • Requires JavaScript knowledge

GTM Tag Firing Rules

Configure when your tags should fire based on consent choices

Analytics Tags

Google Analytics 4

  • • Trigger: analytics_storage = granted
  • • Include consent state in configuration
  • • Use enhanced measurement events

Google Analytics Universal

  • • Trigger: analytics_storage = granted
  • • Configure anonymize IP setting
  • • Set cookie expiration based on consent

Advertising Tags

Google Ads

  • • Trigger: ad_storage = granted
  • • Include conversion tracking
  • • Set up remarketing audiences

Facebook Pixel

  • • Trigger: ad_storage = granted
  • • Configure advanced matching
  • • Set up conversion API

Functional Tags

Chat Widgets

  • • Trigger: functionality_storage = granted
  • • Include user identification
  • • Set up conversation tracking

Personalization

  • • Trigger: personalization_storage = granted
  • • Configure user preferences
  • • Set up recommendation engines

Security Tags

Fraud Detection

  • • Trigger: security_storage = granted (default)
  • • Include device fingerprinting
  • • Set up risk scoring

CAPTCHA

  • • Trigger: security_storage = granted (default)
  • • Configure bot detection
  • • Set up rate limiting

GTM Implementation Step-by-Step

Complete guide to implementing cookie consent with Google Tag Manager

1Set Up Consent Mode v2

Configure Consent Mode v2 in your GTM container:

  1. Go to your GTM container
  2. Navigate to "Tags" → "New"
  3. Choose "Consent Mode" tag type
  4. Set default consent state to "denied"
  5. Configure all required consent types
  6. Set trigger to "All Pages"

2Create Cookie Consent Tag

Add our cookie consent as a Custom HTML tag:

  1. Create new "Custom HTML" tag
  2. Paste your generated cookie banner code
  3. Configure consent update events
  4. Set trigger to "All Pages"
  5. Ensure tag fires before other tags

3Configure Tag Firing Rules

Set up triggers for your existing tags:

  • Create consent-based triggers for each tag type
  • Set Google Analytics to fire only with analytics_storage = granted
  • Configure advertising tags to fire only with ad_storage = granted
  • Set functional tags to fire only with functionality_storage = granted
  • Test all trigger conditions

4Test and Publish

Verify your GTM implementation works correctly:

  • Use GTM Preview mode to test consent flow
  • Verify consent state changes trigger tag updates
  • Check that denied consent prevents tag firing
  • Test all consent categories independently
  • Publish your container and test on live site

Ready to Implement GTM Cookie Consent?

Get started with our GTM cookie consent integration. Complete Consent Mode v2 support, advanced tag management, and full GDPR compliance.