Script blocking to comply with GDPR
-
Hello
As GDPR requires non-functional cookies to be consented by users, I’m trying to figure out how to block scripts should the user decline to be tracked by.I’ve tried making Google Analytics work when the user clicks yes and get blocked by the plugin when the user says no.
I’ve tested it in the real-time overview in Google Analytics, and it seems to be working – but only with Google Chrome. The plugin does not track at all when I click yes in both the newest version of Firefox, Microsoft Edge and Safari on my iPhone 6S.So here’s my question:
For the plugin to block scripts, I need to add them in the “script blocking”-box in the Cookie Notice settings. I’ve done it like this (my unique tracking code removed):if ( function_exists(‘cn_cookies_accepted’) && cn_cookies_accepted() ) {
<!– Global site tag (gtag.js) – Google Analytics –>
<script async src=”https://www.googletagmanager.com/gtag/js?id=xxxxx”></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag(‘js’, new Date());gtag(‘config’, ‘xxxxxxxx’);
</script><!– Google Analytics end –>
}Is this the correct way?
Cheers!
- The topic ‘Script blocking to comply with GDPR’ is closed to new replies.