Google Consent Mode (GCM)

CookieHub offers integration with the recently introduced Google Consent Mode (beta) which helps advertisers to more effectively measure analytics and conversions, while respecting user consent choices for ads cookies and analytics cookies.

Please note that Google Consent Mode is still in beta on Google's side.

Ongoing issues with the GCM solution

While we have fully implemented the solution we have identified issues with the solution and that it may not work as intended.

Ideally when consent mode is enabled but the user has denied analytics, anonymous tracking data would be collected but that doesn't seem to be the case. Requests are sent to Google Analytics but they only show up in real time analytics but then dropped and not accessible in other sections of GA.

[Updated on Feb 17th 2021]  We are actively working with the Google integration team to figure out the cause and resolution.

[Updated on Mar 16th 2021]  We are still waiting for a solution from the Google integration team. We have done thorough research on GCM and can confirm that the issue is not related to CookieHub. This issue also exists with other cookie consent solutions and even when GCM is implemented directly without using a cookie consent solution. Unfortunately we cannot do anything at this point except waiting for solutions from Google.

[Updated on Jun 7th 2021]  We have not received any solutions from Google and don't expect to get one. While GCM does not provide the intended results, it's a great way to integrate CookieHub on your web site without having to modify the Google tags in any way and can be very useful when Google tags are loaded using plugins like Site Kit by Google where you can't modify the integration code to make it compliant with privacy regulations.

How does it work?

With Consent Mode, your Google tags will be able to determine whether or not permission has been given for your site to use cookies for advertising purposes for that user. CookieHub will notify which cookie categories have been allowed and Google Tags supporting GCM will only set cookies if allowed and require no further changes to be fully compliant with data privacy laws.

More information on the Google Marketing Platform

CookieHub and Google Consent Mode

Enabling Google Consent Mode is easy, follow these steps based on how you are currently implementing Google Analytics on your web site.

Direct implementation (delayed javascript)

1. If you have already implemented CookieHub on your web site, remove the data-consent and type tags as they are not required anymore:

<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-XXXXXXXX-X"></script>
<script type="text/plain" data-consent="analytics">
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-XXXXXXXX-X');
</script><br>

2. Add the following code before the <script> tags for your Google Analytics code:

<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('consent', 'default', {'ad_storage': 'denied', 'analytics_storage': 'denied', 'wait_for_update': 500});
</script>

3. Enable Google Consent Mode for your domain in the CookieHub portal by clicking the domain name, clicking the Settings tab.

Thanks all! CookieHub will take care of the rest.

Here’s a fully functional example code:

<!-- Google Consent Mode -->
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('consent', 'default', {'ad_storage': 'denied', 'analytics_storage': 'denied', 'wait_for_update': 500});
</script>

<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-XXXXXXXX-X"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-XXXXXXXX-X');
</script><br>

Google Tag Manager

1. Add the following code above your Google Tag Manager integration code on your web site:

<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('consent', 'default', {'ad_storage': 'denied', 'analytics_storage': 'denied', 'wait_for_update': 500});
</script><br>

2. Change the firing trigger for the Google Analytics tag in GTM to CookieHub – Allowed Analytics or CookieHub – Loaded:

3. Enable Google Consent Mode for your domain in the CookieHub portal by clicking the domain name, clicking the Settings tab.

Thanks all! CookieHub will take care of the rest.

Still need help? Contact Us Contact Us