Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Event Consent State allways 'Granted' in Google #127

Open
SocialGardenAs opened this issue May 2, 2024 · 2 comments
Open

Event Consent State allways 'Granted' in Google #127

SocialGardenAs opened this issue May 2, 2024 · 2 comments

Comments

@SocialGardenAs
Copy link

SocialGardenAs commented May 2, 2024

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"?

@MontiMarco92
Copy link
Collaborator

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
image

When clicking "Accept all" on cookie banner, the GTM consent state gets updated:

image

image

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:

image
image
image

If you have any questions, let me know and I'll try to help.

@ldrolez
Copy link

ldrolez commented Aug 8, 2024

How would you trigger the consent event, using the Analytics ID not the GTM one?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants