Google Tag Manager Integration
Install CookieFrame on your website using Google Tag Manager with full Google Consent Mode v2 support
Google Tag Manager Integration
This guide shows you how to install CookieFrame using Google Tag Manager (GTM). The CookieFrame GTM template includes built-in support for Google Consent Mode v2, making it the recommended integration method for websites already using GTM.
Prerequisites
Before you begin, make sure you have:
- A CookieFrame account with your domain added
- A Google Tag Manager account with a container for your website
- GTM installed on your website
Step 1: Find Your Domain ID
You'll need your CookieFrame Domain ID to configure the GTM template.
- Log in to your CookieFrame Dashboard
- Select your domain from the list
- Navigate to Settings → Integration
- Your 8-character Domain ID is displayed in the integration instructions
[SCREENSHOT PLACEHOLDER: Dashboard showing Domain ID location]
Copy this code—you'll need it in the next steps.
Step 2: Add the CookieFrame Template
- Log in to your Google Tag Manager account
- Select the container for your website
- Go to Tags in the left sidebar
- Click the New button
[SCREENSHOT PLACEHOLDER: GTM Tags section with New button highlighted]
- Click the Tag Configuration area
- Click Discover more tag types in the Community Template Gallery
[SCREENSHOT PLACEHOLDER: Tag Configuration panel showing Community Template Gallery link]
- Search for "CookieFrame"
- Select CookieFrame CMP from the results
[SCREENSHOT PLACEHOLDER: Community Template Gallery search results showing CookieFrame CMP]
- Click Add to workspace to add the template
Step 3: Configure the Template
After adding the template, you'll see the configuration panel:
[SCREENSHOT PLACEHOLDER: CookieFrame CMP tag configuration panel]
Required Settings
| Field | Description |
|---|---|
| Domain ID | Your 8-character CookieFrame Domain ID from Step 1 |
Default Consent Settings (Optional)
Configure how consent types behave before a user makes a choice. In most cases, the defaults are already set correctly for GDPR compliance.
[SCREENSHOT PLACEHOLDER: Default Consent Settings section expanded]
| Consent Type | Recommended Default | Description |
|---|---|---|
ad_storage | Denied | Enables storage for advertising cookies |
ad_user_data | Denied | Enables sending user data to Google for ads |
ad_personalization | Denied | Enables personalized advertising |
analytics_storage | Denied | Enables analytics cookies |
functionality_storage | Denied | Enables website functionality cookies |
personalization_storage | Denied | Enables personalization cookies |
security_storage | Granted | Enables security-related cookies (always on) |
For GDPR compliance, all consent types except security_storage should default to Denied. The user must actively opt in before any tracking occurs.
Regional Consent Defaults (Optional)
If you serve visitors from different regions with different privacy laws, you can configure region-specific defaults.
[SCREENSHOT PLACEHOLDER: Regional Consent Defaults table]
| Region Code | Example Use Case |
|---|---|
US | United States (all states) |
US-CA | California (CCPA requires opt-out, not opt-in) |
DE | Germany |
GB | United Kingdom |
Regional codes follow the ISO 3166-2 standard.
Advanced Settings (Optional)
| Setting | Default | Description |
|---|---|---|
| Inject CookieFrame widget script | Enabled | Loads the consent banner via GTM. Disable only if you're adding the script manually to your HTML. |
| Wait for update (ms) | 500 | Time to wait for user consent before firing tags |
| URL passthrough | Off | Passes ad click information through URL parameters when consent is denied |
| Ads data redaction | On | Redacts ad click identifiers when ad_storage consent is denied |
| Debug logging | Off | Logs consent changes to browser console for troubleshooting |
Step 4: Set the Trigger
The CookieFrame tag must fire on the Consent Initialization trigger to work correctly:
- Click the Triggering area below the tag configuration
- Select Consent Initialization - All Pages
[SCREENSHOT PLACEHOLDER: Trigger selection showing Consent Initialization - All Pages]
Using any other trigger will cause consent mode to malfunction. The Consent Initialization trigger ensures consent defaults are set before any other tags fire.
Step 5: Save and Publish
- Click Save in the top right corner
- Name your tag (e.g., "CookieFrame CMP")
- Click Save again
[SCREENSHOT PLACEHOLDER: Save dialog with tag name]
- Click Submit in the top right to publish your changes
- Add a version name and description, then click Publish
[SCREENSHOT PLACEHOLDER: Submit/Publish dialog]
Verifying Your Installation
Using GTM Preview Mode
- In GTM, click Preview in the top right
- Enter your website URL and click Connect
- Navigate to your website in the new tab
- Return to the Preview tab and check:
- The CookieFrame tag appears in Tags Fired
- The Consent tab shows consent types as "Denied" initially
[SCREENSHOT PLACEHOLDER: GTM Preview mode showing CookieFrame tag fired]
Using Browser Developer Tools
- Open your website in Chrome or Firefox
- Open Developer Tools (F12 or right-click → Inspect)
- Go to the Console tab
- Enable Debug logging in the GTM tag settings (see Advanced Settings)
- Refresh the page and look for messages starting with
[CookieFrame GTM]
[CookieFrame GTM] Initializing CookieFrame consent mode
[CookieFrame GTM] Default consent state set
[CookieFrame GTM] No stored consent found, waiting for user interactionUsing Google Tag Assistant
- Install Google Tag Assistant
- Navigate to your website
- Click the Tag Assistant icon in your browser
- Check the Consent tab to verify consent signals are being sent
How Google Consent Mode Works with CookieFrame
CookieFrame maps its cookie categories to Google's consent types:
| CookieFrame Category | Google Consent Types |
|---|---|
| Necessary | security_storage (always granted) |
| Analytics | analytics_storage |
| Marketing | ad_storage, ad_user_data, ad_personalization |
| Preferences | functionality_storage, personalization_storage |
When a user interacts with the consent banner:
- CookieFrame saves their preferences
- The GTM template immediately updates Google's consent state
- Tags with built-in consent support (Google Analytics, Google Ads, Floodlight) automatically adjust their behavior
Script Blocking with GTM
CookieFrame uses a two-tier approach to ensure comprehensive consent management:
| Tier | What it Controls | How it Works |
|---|---|---|
| Google Consent Mode | Tags inside GTM (GA4, Google Ads) | GTM's built-in consent APIs |
| Script Blocker | Scripts embedded directly in HTML | DOM interception |
Why Two Tiers?
When GTM fires a tag like Google Analytics, it doesn't create a visible <script> element in your page's HTML. Instead, GTM executes code internally. This means:
- Consent Mode is the only way to control tags managed by GTM
- Script Blocker is needed for scripts you've added directly to your HTML (outside GTM)
Example Scenario
If your website has:
- GA4 and Google Ads tags in GTM → Controlled by Consent Mode
- Facebook Pixel added directly to HTML → Controlled by Script Blocker
Both systems work together automatically. The GTM container itself is never blocked.
If you have Auto Block Scripts enabled in CookieFrame and also use GTM, both systems work together. GTM handles its own tags via Consent Mode, while CookieFrame blocks any other scripts embedded directly in your HTML.
Excluding Scripts from Blocking
If you have scripts that should never be blocked (besides GTM, which is automatically excluded), add the data-cookieframe="ignore" attribute:
<!-- This script will never be blocked -->
<script src="https://example.com/essential-script.js" data-cookieframe="ignore"></script>CookieFrame also recognizes data-cookieconsent="ignore" for compatibility with Cookiebot migrations.
Google Consent Mode Settings in CookieFrame
You can configure Google Consent Mode behavior in your CookieFrame dashboard under Settings → Integration.
Basic Mode vs Advanced Mode
Google Consent Mode supports two implementation modes:
| Mode | Behavior | Best For |
|---|---|---|
| Basic Mode (default) | Google tags are completely blocked until consent is given. No data is sent to Google before the user makes a choice. | Strictest GDPR compliance, privacy-focused sites |
| Advanced Mode | Google tags fire immediately with cookieless pings, but full tracking only activates after consent. This enables Google's conversion modeling for better analytics accuracy. | Sites that need conversion modeling, e-commerce |
Advanced Mode still respects user consent—it just allows Google to collect anonymized, cookieless data for modeling purposes before consent is given. This helps recover analytics data lost due to consent requirements.
Wait for Consent Update
The Wait for update setting controls how long Google tags wait for consent before firing with default (denied) values. The default is 500 milliseconds.
| Setting | Description |
|---|---|
| 100-500ms | Faster tag firing, may miss consent if banner loads slowly |
| 500ms (default) | Balanced setting for most websites |
| 1000-2000ms | More time for consent, recommended for slower sites or complex consent flows |
This setting is available in both the GTM template configuration and the CookieFrame dashboard under Settings → Integration → Google Consent Mode v2.
Debug Mode
Enable Debug Mode to log all Google Consent Mode operations to the browser console. This helps troubleshoot consent signaling issues.
When enabled, you'll see messages like:
[CookieFrame GCM] setDefaultGoogleConsentMode() called
[CookieFrame GCM] Calling gtag('consent', 'update', ...)
[CookieFrame GCM] gtag consent update called successfullyVerify Setup
Click Verify Setup to check that Google Consent Mode is properly configured. This checks:
- Widget configuration exists
- Google Consent Mode is enabled
- Widget has been published
- Domain is active
Configuring Other Tags for Consent
Tags from Google (GA4, Google Ads, Floodlight) have built-in consent mode support and work automatically. For third-party tags, you need to configure consent settings manually.
Adding Consent Checks to Tags
- Open the tag you want to configure
- Scroll to Consent Settings
- Click Require additional consent for tag to fire
- Add the appropriate consent types:
- For analytics tags:
analytics_storage - For advertising tags:
ad_storage
- For analytics tags:
[SCREENSHOT PLACEHOLDER: Tag consent settings configuration]
Using the Consent Overview
GTM provides a Consent Overview to help identify tags that may need configuration:
- Go to Tags in the left sidebar
- Click the Consent Overview icon (shield icon)
- Review tags marked as "No consent configured"
Troubleshooting
The consent banner doesn't appear
- Verify your Domain ID is correct (8 characters, uppercase)
- Check that "Inject CookieFrame widget script" is enabled
- Ensure the domain in CookieFrame matches your website exactly
- Check the browser console for errors
Tags fire before consent is given
- Confirm the CookieFrame tag uses the Consent Initialization - All Pages trigger
- Verify other tags have appropriate consent settings configured
- Check that consent defaults are set to "Denied"
Consent state doesn't update after user choice
- Enable debug logging and check console for errors
- Verify the CookieFrame widget is loading correctly
- Clear your browser's localStorage and try again
Returning visitors aren't recognized
CookieFrame stores consent in localStorage under the key cf_consent. If this is cleared (e.g., by browser privacy settings), consent must be given again.
Next Steps
Need Help?
If you're having trouble with the GTM integration:
- Email us at support@cookieframe.com
- Check our FAQ for common questions