The cart is empty

Google Consent Mode v2 is an updated version of the tool that allows websites to adjust data collection based on user consent. This new version reflects stricter privacy requirements, particularly under GDPR and other regulations.

Why Implement Google Consent Mode v2?

  • Compliance with legal regulations – Ensures your website adheres to European privacy laws.

  • Preservation of analytical data – Even if users refuse consent, aggregated data can still be collected.

  • Optimization of advertising – Proper configuration enables more effective management of personalized ads.

Steps to Implement Google Consent Mode v2

1. Ensuring a Compatible CMP (Consent Management Platform) Consent Mode v2 requires a compatible CMP that supports the new parameters. Recommended platforms include Cookiebot, OneTrust, or Google Consent Management Platform.

2. Updating the Code for Google Tag Manager or gtag.js If you are already using Google Tag Manager or gtag.js, implementation needs to be adjusted.

  • Implementation via Google Tag Manager (GTM):

    1. Open GTM and add a new tag of type Custom HTML Script.

    2. Insert the following code:

    <script>
    window.dataLayer = window.dataLayer || [];
    function gtag(){dataLayer.push(arguments);}
    gtag('consent', 'default', {
        'ad_storage': 'denied',
        'analytics_storage': 'denied',
        'functionality_storage': 'granted',
        'security_storage': 'granted'
    });
    </script>
    1. Add conditions to modify user consent using CMP variables.

  • Implementation via gtag.js: If you are not using GTM, add the following script to the website header:

    <script async src="https://www.googletagmanager.com/gtag/js?id=UA-XXXXXXX-X"></script>
    <script>
    window.dataLayer = window.dataLayer || [];
    function gtag(){dataLayer.push(arguments);}
    gtag('js', new Date());
    
    gtag('consent', 'default', {
        'ad_storage': 'denied',
        'analytics_storage': 'denied',
        'functionality_storage': 'granted',
        'security_storage': 'granted'
    });
    </script>

3. Adding Dynamic Consent Updates Consent Mode v2 allows for updating consent settings based on user preferences. After changing settings in the CMP, consent values must be modified in Google Tag Manager or gtag.js.

Example of a script for updating consent:

<script>
  gtag('consent', 'update', {
      'ad_storage': 'granted',
      'analytics_storage': 'granted'
  });
</script>

4. Testing the Implementation After implementation, it is crucial to verify proper functionality. Useful tools include:

  • Google Tag Assistant – Checks the correct configuration of tags.

  • Google Consent Mode Debugger – A tool to verify consent implementation.

  • Chrome DevTools – Monitors network requests for cookies and data.

5. Deployment and Monitoring Once testing is successful, deploy the changes to the live version of your website and monitor user behavior in Google Analytics and Google Ads.

 

Implementing Google Consent Mode v2 is a key step to ensuring compliance with legal regulations and optimizing data collection. A proper implementation enables effective use of analytical and advertising tools without violating user privacy.

Star InactiveStar InactiveStar InactiveStar InactiveStar Inactive