Cookie block
-
Hi – this is a great plugin and is by far the best one out there for cookies and general GDPR compliance.
I’m just tearing my hair out in terms of how to block the GA script by default.
I’d like to include this via a helper function in functions.php but I’ve added this in and I just get a 500 error. As far as I can see the syntax is correct, it just dies when I add this in.
function analytics_snippet() { if ( is_allowed_cookie( '_ga' ) { ?> <script> (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','https://www.google-analytics.com/analytics.js','ga'); ga('create', 'UA-xxxxxxxx-x', 'auto'); ga('send', 'pageview'); </script> <?php } }
(xxxxxx-x is replaced with my analytics ID)
I’ve set-up a tab called ‘analytics’ and listed the cookie I’m trying to block as _ga
Am I missing something really simple or should this work?
Thank you!
Geoff
Viewing 14 replies - 1 through 14 (of 14 total)
Viewing 14 replies - 1 through 14 (of 14 total)
- The topic ‘Cookie block’ is closed to new replies.