Hi @stevendigital,
Can you provide an URL to the website in question, so we can take a look?
Kind regards, Jarno
Hi @stevendigital,
Can you try it with the following Statistics configuration in the Complianz Wizard?
– Wizard -> Consent -> Statistics, “Yes, with Google Analytics” + the three checkboxes enabled under “Does the following apply to your website”
– Wizard -> Consent -> Statistics – configuration, Do you want to ask consent for statistics? “No”, Do you want Complianz to add Google Analytics to your website? “No”
Kind regards, Jarno
Thread Starter
Efs
(@stevendigital)
Hello, @jarnovos
Thank you for your response.
I did the above suggestion but still the script remains as is.
Here is the site in question https://www.temporary-url.com/FB60
I use a simple plugin to add the scripts to header.
Let me know if you need anything else.
Best Regards
Hi @stevendigital,
Are you using the exact code from the article, or are there modifications which I might be missing here? I can’t seem to get the same behavior that you described when copying the code from the article and setting the options that I described above.
It looks as if there’s still some difference between my and your set-up that I’m not aware of, so it’s challenging to indicate the exact culprit. You might have to try some variations to see what works best for your case.
In any case. my honest recommendation would be to just place these tags via the Complianz Wizard, by selecting “Yes, with Google Analytics” and letting Complianz place the script; whereby you could just enter the desired tags in the Wizard directly.

Kind regards, Jarno
Thread Starter
Efs
(@stevendigital)
Here is the code I implement
$g_code_id = 'g-code';
$aw_code_id = 'aw-code';
function add_scripts_in_header() {
global $g_code_id, $aw_code_id;
if (!is_admin()) {
?>
<script type="text/plain" data-category="marketing" src="https://www.googletagmanager.com/gtag/js?id=<?php echo $aw_code_id; ?>"></script>
<script type="text/javascript" data-category="functional" async src="https://www.googletagmanager.com/gtag/js?id=<?php echo $g_code_id; ?>"></script>
<script type="text/plain" data-category="marketing">
window.dataLayer = window.dataLayer || [];
function gtag() { dataLayer.push(arguments); }
gtag('js', new Date());
// Remarketing for Google Ads - Marketing Category
gtag('config', '<?php echo $aw_code_id; ?>');
</script>
<?php
}
}
add_action('wp_head', 'add_scripts_in_header');
I do not use any plugins to add it. Just this code through the use of an mu-plugin
Unfortunately, I can not use the fields on Complianz.
Best Regards
Hi @stevendigital,
The only way I can reproduce similar behavior when using your exact code snippet is when I configure Complianz in such a way, that the plugin deems obtaining explicit consent for Statistics required.
I would therefore recommend you to check all of these settings to ensure that the plugin does not find this to be necessary.
– Wizard -> General -> Visitors: Do you target visitors from Germany, Austria, Belgium and/or Spain? “No”
– Wizard -> Consent -> Statistics: “Yes, with Google Analytics”
– Wizard -> Consent -> Statistics: Enable the three checkboxes under “Does the following apply to your website”
– Wizard -> Consent -> Statistics – configuration: Do you want to ask consent for statistics? “No”
– Wizard -> Consent -> Statistics – configuration: Do you want Complianz to add Google Analytics to your website? “No”
As we’re using the same code, this would seem to be the main difference between our setups.
Kind regards, Jarno
Hi @stevendigital,
I would like to add that while we can, of course, provide support for configuring your Google Tags via the plugin’s Wizard: as this concerns implementation of the tags via (custom) code, so I’d recommend trying some different approaches on your end to figure out what works best with your desired setup.
Kind regards ,Jarno
Thread Starter
Efs
(@stevendigital)
Hello @jarnovos,
I have also set this setting as per your suggestion –> Wizard -> General -> Visitors: Do you target visitors from Germany, Austria, Belgium and/or Spain? “No”
I can see that the script is added properly now, but the category is removed.
Here is the script that appears on the header:
<script src="https://www.googletagmanager.com/gtag/js?id=AW-code" data-cmplz-src="https://www.googletagmanager.com/gtag/js?id=AW-code" class="cmplz-activated"></script>
All the other settings are also set as per your suggestions.
I think that the problem is with how the plugin handles different scenarios and how the script code is handled. I understand that the settings must be set properly, in order to avoid conflicts with codes of analytics that also use googletagmanager.com but here is a different case.
You can see that the custom code is not doing anything more, than adding the script in the header. Regardless of whether it uses a variable for the AW ID, or a fixed ID value, there is no interference with how Complianz handles the script implementation in the header or if it removes or not the data-category. This is all done by the plugin’s logic and not by the custom script.
I do not know if I miss something here, but please can you take a closer look?
If I can help with anything, please inform me.
Best Regards
@stevendigital
The script is likely still deemed a “Statistics” script, but with the adjusted configuration in Complianz it can now be loaded immediately; so the cmplz-activated part appears instead of those previous attributes, as it’s now loaded.
I don’t think there’s much more I can do to change that from my end. If more control is required with regards to these tags and when they fire, without the script attributes being affected by the plugin as well, consider using Tag Manager instead of Analytics, to fire each of the Google Tags based on a desired consent type (https://complianz.io/definitive-guide-to-tag-manager-and-complianz/ -> “(Step-by-step) Firing tags based on consent in Tag Manager”).
Kind regards, Jarno