Please note: The below guide was originally drafted to help implement Cookiebot prior to the release of our automated cookie control functionality on September 10th 2019.
You may still be using and preferring the manual implementation and markup option.
In that case the below guide may still be relevant for you.
For automatic cookie blocking please follow the implementation guide here: https://cookiebot.com/goto/help
The manual method for implementing prior consent on GA Universal
To enable prior consent on GA Universal, apply the attribute "data-cookieconsent" to the GA Universal script tag on your website. Set the comma-separated value of the attribute to "statistics" in accordance with the types of cookies being set by the script. Finally change the attribute "type" from "text/javascript" to "text/plain". Make sure to use your own GA Universal code instead of 'UA-0000000-0':<script type="text/plain" data-cookieconsent="statistics"> (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); ga('create', 'UA-00000000-0', 'auto'); ga('send', 'pageview'); </script>
An alternative method if you want to load GA Universal dynamically
Insert the following JavaScript callback function 'CookiebotCallback_OnAccept' in your website's HTML header. Make sure to use your own GA Universal code instead of 'UA-0000000-0':function CookiebotCallback_OnAccept () { if(Cookiebot.consent.statistics) { enableGoogleAnalyticsUniversal(); } }
function enableGoogleAnalyticsUniversal() { (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); ga('create', 'UA-00000000-0', 'auto'); ga('send', 'pageview'); }
Read more: Is my use of Google Analytics GDPR and ePR compliant?
Comments
0 comments
Article is closed for comments.