I've been trying all day to get this package to work correctly with a website that uses a Google tag container with tiktok / FB pixel tags. These pixels were firing before I made any selection on the consent banner. I believe this is because we are waiting for DOMContentLoaded to set the initial consent to denied, and by that time the pixels have already fired.
These pixels are not compatible with consent mode by default so we have to enable that on each tag in tag manager under advanced options and add the 'ad_storage' option 'Require additional consent for tag to fire'.
Doing that alone is not enough though. I had to add this block of code above AltCookies code in order to prevent these pixels from firing:
<script>
(function() {
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
var match = document.cookie.match(new RegExp('(^| )AltCookieAddon=([^;]+)'));
var cookieVal = match ? match[2] : null;
if (cookieVal === "4") {
gtag('consent', 'default', { 'ad_storage': 'granted', 'ad_user_data': 'granted', 'ad_personalization': 'granted', 'analytics_storage': 'granted' });
} else if (cookieVal === "3") {
gtag('consent', 'default', { 'ad_storage': 'granted', 'ad_user_data': 'granted', 'ad_personalization': 'granted', 'analytics_storage': 'denied' });
} else if (cookieVal === "2") {
gtag('consent', 'default', { 'ad_storage': 'denied', 'ad_user_data': 'denied', 'ad_personalization': 'denied', 'analytics_storage': 'granted' });
} else {
gtag('consent', 'default', { 'ad_storage': 'denied', 'ad_user_data': 'denied', 'ad_personalization': 'denied', 'analytics_storage': 'denied' });
}
})();
</script>
By the way, these pixels are not consent_mode compatible by default so I had to enable that and 'ad_storage' in advanced settings in my google tags.
Does this make sense? Am I doing something wrong?
Thanks!
I've been trying all day to get this package to work correctly with a website that uses a Google tag container with tiktok / FB pixel tags. These pixels were firing before I made any selection on the consent banner. I believe this is because we are waiting for DOMContentLoaded to set the initial consent to denied, and by that time the pixels have already fired.
These pixels are not compatible with consent mode by default so we have to enable that on each tag in tag manager under advanced options and add the 'ad_storage' option 'Require additional consent for tag to fire'.
Doing that alone is not enough though. I had to add this block of code above AltCookies code in order to prevent these pixels from firing:
By the way, these pixels are not consent_mode compatible by default so I had to enable that and 'ad_storage' in advanced settings in my google tags.
Does this make sense? Am I doing something wrong?
Thanks!