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.
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.
Google Analytics 4 is our next-generation measurement solution, and it's replacing Universal Analytics. July 1, 2023, standard Universal Analytics properties will stop processing new hits. If you still rely on Universal Analytics, we recommend that you prepare to use Google Analytics 4 going forward.
For automatic cookie blocking please follow the implementation guide here: https://cookiebot.com/goto/help
The manual method for implementing prior consent on Google Universal Analytics
To enable prior consent on Google Universal Analytics, apply thedata-cookieconsent
attribute to the Google Universal Analytics 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 type
attribute from "text/javascript" to "text/plain". Make sure to use your own Google Universal Analytics 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 Google Universal Analytics dynamically
Insert the following JavaScript callback function 'CookiebotCallback_OnAccept' in your website's HTML header. Make sure to use your own Google Universal Analytics 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
Please sign in to leave a comment.