I have an issue I have tried to solve for days now but I haven’t succeeded. After setting up the plugin Complianz I noticed that my traffic wasn’t at all what it used to be. After using TagBird I figured that it is because Google Analytics is blocked before consent.
In the complianz wizard, I have completed & checked the 3 boxes so that statistics are set to anonymous. I have set the ‘Do you want to ask consent for statistics?’ to No. I have set the ”Do you want Complianz to add Google Analytics to your website?” to yes, and provided my UA tracking ID.
Regardless, complianz still blocks Google Analytics before consent is given.
I would be really really thankful for any help, as I would love to continue using complianz!
But in the code of your website I see consent is indeed still needed for consent. The difference is an attribute in the script itself. Could it be you’re serving static HTML and you need to publish again, clear caching or similar?
Or maybe there’s something in your script center that triggers on analytics as well.
Before we find out why, you could circumvent this by whitelisting “tagmanager.com” and “gtag()” in the script center.
Or in the wizard, disable Complianz adding the script and adding it yourself with an attribute for example:
<!-- Global site tag (gtag.js) - Google Analytics -->
<script data-category="functional" async src="https://www.googletagmanager.com/gtag/js?id=YOURCODE"></script>
<script data-category="functional">
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'YOURCODE');
</script>
<!-- Analytics -->
I’m no web developer and I learn as I go, so it takes me some time to understand it all. 🙂
I don’t know if I’m serving static HTML. I guess I’m not because I don’t even know what it meant (before I googled it).
2. I’ve checked the script center in Complianz and nothing was activated there except for whitelisting Burst statistics.
I’ve now whitelisted tagmanager.com and gtag() in complianz script center like this: https://postimg.cc/KRzKwCxh (which is hopefully the correct way). Do I need to configure the wizard again after this? Because right now it doesn’t make a difference for what I can see.
Let’s continue with the “whitelisting” route for now, and if that doesn’t work; we’ll try an alternative approach.
I see that you have the scripts added to the whitelist, but they are ‘comma-separated’ at the moment. They have to be added on separate lines, which you can do by clicking the + icon.
I can’t quite explain why it happens, especially as the same configuration works on the example site that @aahulsebos attached earlier: but we can go for a manual implementation instead.
An easy way to go about this would be to use the Header Footer Code Manager (HFCM) plugin to easily add code snippets, although you can also add this in a file of your theme, if preferred.
With the HFCM plugin activated, follow these steps:
Navigate to Complianz > Wizard > Consent > Statistics – confguration and answer “Do you want Complianz to add Google Analytics to your website?” with No.
Create a new snippet in HFCM, set the Snippet Type to “JavaScript”, the Location to “Footer” and the Status to “Active”
Copy the below lines to the snippet/code field, and Save when done.
<!-- Global site tag (gtag.js) - Google Analytics -->
<script data-category="functional" async src="https://www.googletagmanager.com/gtag/js?id=UA-158585795-1"></script>
<script data-category="functional">
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-158585795-1');
</script>
<!-- End Analytics -->
Your Analytics script for the “UA-” property should now load without requiring Statistics consent.
I already had a plugin like that called WPCode lite, so after I set “Do you want Complianz to add Google Analytics to your website?” to ”No”, I pasted the code you provided in the header section (as google recommends pasting the analytics code in the header for more accurate tracking).
It now finally seems to work!! 😀
However, I had a last question: Are the IP addresses also anonymized with the code you provided? Or do I need to alter the code in some way so that happens?
Really grateful for all the help! Best regards, Bo