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.

For information on how to use Consent Mode in Google Tag Manager, use the Consent Mode in Google Tag Manager article instead.

How does it work?

With Consent Mode, Google tags supporting Consent Mode will be able adjust behaviour based on signals from CookieHub to determine whether or not permission has been given to use cookies for advertising or analytical purposes without any changes to the scripts.

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 and change the type from text/plain to text/javascript:

<!-- 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>

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 for Google Analytics with Consent Mode:

<!-- 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>

Google Tag Manager

For information on how to use Consent Mode in Google Tag Manager, use the Consent Mode in Google Tag Manager article.

Still need help? Contact Us Contact Us