Google Consent Mode v2

Learn how Cookient integrates with Google Consent Mode v2 for compliant analytics and advertising in the EU/EEA.

Overview

Google Consent Mode v2 is a framework that allows Google tags (Analytics, Ads, etc.) to adjust their behavior based on user consent. Since March 2024, it's required for advertisers targeting users in the EU/EEA.

!
Required for EU Advertisers
If you run Google Ads campaigns targeting EU/EEA users and don't implement Consent Mode v2, you will lose audience data and remarketing capabilities.

Why It Matters

  • Legal compliance – Required by GDPR and ePrivacy
  • Preserve analytics – Cookieless pings still provide aggregated data
  • Remarketing – Required for Google Ads audiences in EU

How It Works

Cookient automatically communicates consent status to Google services through the gtag('consent', ...) API.

  1. 1

    Default State

    When the page loads, Cookient sets all consent types to denied by default.

  2. 2

    User Interaction

    User sees the consent banner and makes their choices.

  3. 3

    Consent Update

    Cookient calls gtag('consent', 'update', ...) with the user's choices.

  4. 4

    Tag Behavior

    Google tags adjust automatically – full tracking if granted, cookieless pings if denied.

Example Consent Update

gtag('consent', 'update', {
  'ad_storage': 'granted',
  'ad_user_data': 'granted',
  'ad_personalization': 'granted',
  'analytics_storage': 'granted'
});

Setup

Google Consent Mode is enabled by default in Cookient. Here's how to verify it's working correctly with your Google tags.

Step 1: Install Cookient First

The Cookient script must load before any Google tags. This ensures the default consent state is set before Google starts tracking.

Correct Script Order

<head>
  <!-- 1. Cookient FIRST -->
  <script src="https://cookient.app/c/YOUR_TOKEN.js"></script>

  <!-- 2. Google Tag Manager or gtag.js AFTER -->
  <script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXX"></script>
  <script>
    window.dataLayer = window.dataLayer || [];
    function gtag(){dataLayer.push(arguments);}
    gtag('js', new Date());
    gtag('config', 'G-XXXXXX');
  </script>
</head>

Step 2: Verify in Google Tag Assistant

  1. Install the Google Tag Assistant browser extension
  2. Visit your website and open Tag Assistant
  3. Look for "Consent" section in tag details
  4. Verify consent state changes when you interact with the banner

Step 3: Check GA4 Real-Time Reports

In Google Analytics 4, go to Reports → Real-time. You should see events coming in with consent status indicated.

Testing

Test your Consent Mode implementation to ensure it's working correctly.

Using Browser DevTools

  1. Open DevTools → Console
  2. Type dataLayer and press Enter
  3. Look for consent events in the array
  4. Verify default shows denied initially
  5. Accept cookies and check for update with granted

Using Network Tab

  1. Open DevTools → Network
  2. Filter by "collect" or "google"
  3. Before consent: Look for gcs=G100 (all denied)
  4. After accepting all: Look for gcs=G111 (all granted)

GCS Parameter Values

gcs=G100  → All denied (default state)
gcs=G110  → Analytics granted, Ads denied
gcs=G101  → Analytics denied, Ads granted
gcs=G111  → All granted

Troubleshooting

Consent state not updating

Cause: Google tags loaded before Cookient.

Solution: Move the Cookient script to load before all Google tags in your <head>.

"Consent not detected" in Tag Assistant

Cause: gtag function not available when Cookient initializes.

Solution: Ensure you have the gtag.js base code installed, even if using GTM.

No data in GA4 after denying consent

This is expected behavior. When analytics consent is denied, Google Analytics respects this and doesn't collect identifiable data.

You may still see aggregated, cookieless pings that provide basic metrics without personal data.

Remarketing audiences not building

Cause: Users are not consenting to Marketing category.

Solution: This is expected – you can only build audiences from users who consent. Consider making your consent request clearer about the benefits of personalized ads.