Support articles

Before contacting the support team, check if your question is already answered here.

How to Integrate with Google Consent Mode v2

Google Consent Mode v2 allows you to control how Google tags behave based on user consent choices. This guide will walk you through the integration process step by step.

Prerequisites

Before starting, ensure you have:

  • Access to your website's code or content management system
  • Google Tag Manager or Google Analytics already set up on your site
  • A consent management platform (like CookieForte) installed

Step 1: Configure Your Consent Banner

  1. Navigate to Websites and banners in your consent management platform
  2. Choose your banner from the list
  3. Click on Settings
  4. Enable the Google Consent Mode v2 setting

This setting ensures your consent banner communicates properly with Google's consent framework.

Step 2: Add the Consent Mode Script

You need to add a consent initialization script to your website before your Google Tag Manager or Google Analytics script loads.

Implementation Code

Add the following script to your website's <head> section, placing it before any Google tracking scripts:

    <script>
        window.dataLayer = window.dataLayer || [];

        function gtag() {
            dataLayer.push(arguments);
        }

        gtag('consent', 'default', {
            'ad_storage': 'denied',
            'analytics_storage': 'denied',
            'functionality_storage': 'denied',
            'personalization_storage': 'denied',
            'security_storage': 'granted',
            'ad_user_data': 'denied',
            'ad_personalization': 'denied',
              'wait_for_update': 500
        });

        gtag("set", "ads_data_redaction", true);
        gtag("set", "developer_id.dMmY1Mm", true);
    </script>

Understanding the Consent Parameters

Parameter Default Value Description
ad_storage denied Controls storage for advertising purposes
analytics_storage denied Controls storage for analytics purposes
functionality_storage denied Controls storage for website functionality
personalization_storage denied Controls storage for personalization
security_storage granted Controls storage for security (typically always granted)
ad_user_data denied Controls sharing of user data for advertising
ad_personalization denied Controls personalized advertising
wait_for_update 500 Time in milliseconds to wait for consent updates

Step 3: Verify Your Implementation

To ensure everything is working correctly, use the Google Tag Assistant Chrome extension:

Installation and Testing

  1. Install Google Tag Assistant: Add the extension from the Chrome Web Store
  2. Open your website in a new tab
  3. Access the side panel: Google tags should appear in the Tag Assistant side panel
  4. Navigate to tag details: Click on TagPageviewFormat
  5. Check consent status: Verify that ad_storage and analytics_storage show as "denied" or "granted" according to user Statistics and Marketing settings in CookieForte banner

What to Look For

  • Initially, storage parameters should show as "denied" (before user consent)
  • After user grants consent through your banner, the parameters should update to "granted"
  • The consent state should match your banner's configuration

Troubleshooting

Common Issues

Script not loading: Ensure the consent script is placed before all Google tracking scripts in your HTML.

Consent not updating: Check that Enable Google Consentv2 is enable in CookieForte platform.

Best Practices

  • Always set initial consent to "denied" for data protection compliance
  • Use security_storage: 'granted' as it's typically required for basic website security

Additional Resources