Open SocialGardenAs opened 4 months ago
Hi, I tried to check your site but it seems you have other cookie consent solution implemented. But in case it helps you, I'll share an example
The implemented code is as follows:
<script>
window.dataLayer = window.dataLayer || [];
function gtag() {
dataLayer.push(arguments);
}
const defaultSettings = {
ad_storage: 'granted',
ad_user_data: 'granted',
ad_personalization: 'granted',
analytics_storage: 'granted',
};
const defaultRegionalSettings = {
ad_storage: 'denied',
ad_user_data: 'denied',
ad_personalization: 'denied',
analytics_storage: 'denied',
region: [
'AT',
'BE',
'BG',
'HR',
'CY',
'CZ',
'DK',
'EE',
'FI',
'FR',
'DE',
'GR',
'HU',
'IE',
'IT',
'LV',
'LT',
'LU',
'MT',
'NL',
'PL',
'PT',
'RO',
'SK',
'SI',
'ES',
'SE',
'IS',
'LI',
'NO',
],
};
if (localStorage.getItem('consentMode') === null) {
gtag('consent', 'default', defaultSettings);
gtag('consent', 'default', defaultRegionalSettings);
} else {
gtag('consent', 'default', {
...defaultRegionalSettings,
...JSON.parse(localStorage.getItem('consentMode')),
});
gtag('consent', 'default', {
...defaultSettings,
...JSON.parse(localStorage.getItem('consentMode')),
});
}
(function (w, d, s, l, i) {
w[l].push({ 'gtm.start': new Date().getTime(), event: 'gtm.js' });
var f = d.getElementsByTagName(s)[0],
j = d.createElement(s),
dl = l != 'dataLayer' ? '&l=' + l : '';
j.async = true;
j.src = 'https://www.googletagmanager.com/gtm.js?id=' + i + dl;
f.parentNode.insertBefore(j, f);
})(window, document, 'script', 'dataLayer', GTM-ID');
</script>
When page loads there's no cookie set, so on GTM the consent state is correctly set as de default's
When clicking "Accept all" on cookie banner, the GTM consent state gets updated:
If, then, I edit consent again and switch all all non-essential cookies to 'off" and 'Save settings', the cookie gets updated and a new consent update is triggered on GTM:
If you have any questions, let me know and I'll try to help.
How would you trigger the consent event, using the Analytics ID not the GTM one?
How would you trigger the consent event, using the Analytics ID not the GTM one?
I finally replaced the j.src line with this one, and everything works perfectly:
j.src = 'https://www.googletagmanager.com/gtag/js?id=' + i + dl;
Hi. I'm about to implement Brainsum Cookie Consent Mode v2 on my webpage. It seems to work fine, but when I debug with Google Tag Assistent it seems like something is wrong.
I run Google Tag Assistant on this website: https://test.nettdating.no.
Output of AW-959228164 and G-SMHSHTEPSS returns Event Consent State 'Denied' on 'ad_storage', 'analytics_storage', 'ad_user_data' and 'ad_personalization' by default. That seems to be correct. When I click "Accept all cookies" on the consent banner, I get 'Granted' on all Event Content States. Thats seems to be correct as well.
But, if I choose "Cookie Settings" and "Save current settings" with everything 'Off' (default selection), I still get 'Granted' on all Event Content States in Google Tag Assistant. That seems to be wrong, since Analytics, Marketing and Various Cookies was turned off.
Why is Event Consent State set to Granted, even if everything is turned off before clicking "Save current settings"?