Integrating GCM v2 for Google Services without GTM

Last updated on August 13, 2024

CookieYes is a Google-Certified CMP and integrates with Google Consent Mode v2.

This guide walks you through the process of integrating Google Consent Mode v2 (GCM v2) for various Google services such as Google Analytics, Google Ads, and Google Marketing Platform using CookieYes without relying on Google Tag Manager (GTM).

How to Enable Google Consent Mode v2 in CookieYes?

To implement Google Consent Mode v2, the first crucial step is to enable this feature on the CookieYes platform. By default, the Basic Consent Mode should be enabled, but if it has been disabled, follow these steps to reactivate it:

  1. Log in to your CookieYes web app account.
  2. Navigate to CookieYes Dashboard > Advanced Settings.
  3. Under Google Consent Mode (GCM), toggle the button labelled Support GCM to enable Basic Consent Mode.


  4. To configure Advanced Consent Mode in GCM, toggle the button labelled Allow Google tags to fire before consent.

Enabling only the Support GCM option activates basic functionality, allowing only permitted tags based on user consent. Activating the Allow Google tags to fire before consent option ensures that Google tags fire even before the user consents to the banner. 

Help Guide

Please refer to the Basic vs. Advanced Consent Mode v2 Documentation for detailed information on the Basic and Advanced Consent Mode v2 in CookieYes.

Integrate Google Consent Mode v2

Step 1: Add the Custom Consent Mode Script.

Copy the following custom script and paste it in the <head> section of your HTML above the CookieYes script:

<script>
    window.dataLayer = window.dataLayer || [];
    function gtag() {
        dataLayer.push(arguments);
    }
    gtag("consent", "default", {
        ad_storage: "denied",
        ad_user_data: "denied", 
        ad_personalization: "denied",
        analytics_storage: "denied",
        functionality_storage: "denied",
        personalization_storage: "denied",
        security_storage: "granted",
        wait_for_update: 2000,
    });
    gtag("set", "ads_data_redaction", true);
    gtag("set", "url_passthrough", true);
</script>

Note

The values of ads_data_redaction and url_passthrough in the code are changeable as per your requirements. e.g.

gtag("set", "ads_data_redaction",false);
 gtag("set", "url_passthrough",false);

For more detailed information, please refer to the Google Developer Documentation.

Step 2:Add the Google Service Script

If you’re using any Google services that utilize the gtag.js script (such as Google Analytics, Google Ads or Google Marketing Platform), add the appropriate gtag.js script immediately after the CookieYes script.

Step 3:Ensure Proper Script Order

The final order of scripts in your <head> the section should be:

  1. Custom Consent Mode script
  2. CookieYes script
  3. Google services script

This specific order is necessary for proper functionality.

Verify Integration

To verify GCM integration on your website,

  1. Go to Dashboard > Advanced Settings.
  2. Scroll to the Google Consent Mode (GCM) section.
  3. Click the Check now button against Check GCM status to run a configuration check.
check GCM status

To further confirm the setup is correct, follow the steps in our Verification Documentation.

Conclusion

By implementing Google Consent Mode v2 for your Google services as outlined in this guide, you’ve taken a significant step towards balancing user privacy with effective data collection. This implementation allows you to respect user consent choices while still gathering valuable insights from consenting users, helping you comply with privacy regulations and leverage Google’s powerful tools.

If you encounter any issues during or after implementation, our comprehensive Troubleshooting Guide and dedicated GCM support team are available to assist you. 

Have more questions?

Reach out to us and we'll answer them.

Contact us