We are using Google Analytics consent mode (Beta). I believe my implementation is correct, following the official documentation. However, I can't see (in GTM "preview mode") a difference of behavior whether I opt-in or opt-out of tracking. Tags are fired and marked as "succeedeed" in both case. I'm wondering if my implementation is working. (of course I'm clearing cookies and cache between test sessions)
What should I see or NOT see if consent is denied? Is there a difference I should see that would tell me if the consent is taken into account? How can I tell if GTM is tracking or not?
For info, my implementation:
<head>
<script>
// gtm snippet...
</script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() { dataLayer.push(arguments); }
gtag("consent", "default", {
// yes, everything is granted by default (not an EU site)
ad_storage: "granted",
analytics_storage: "granted",
functionality_storage: "granted",
personalization_storage : "granted",
security_storage : "granted",
wait_for_update: 10000, // comfortable timer for starter, will fine-tune it later
});
dataLayer.push({ 'event': 'default_consent' });
</script>
//later after the main js is loaded
gtag("consent", "update", {
ad_storage: "denied", // or granted, depending on user choice
analytics_storage: "denied",
functionality_storage: "denied",
personalization_storage : "denied",
security_storage : "denied",
});
Bonus question: is my setup with a default to "granted" later updating to "denied" a supported case? Could that be the reason I see my tags fired all the time?
You will see requests no matter is the status is granted or denied - in fact, that is the point of Consent Mode, to allow for data collection, even when the user objects to having personal identifiers created.
What you should not see, is cookies being created. However your setup is a bit unusual, in that you initially set the status to granted. Usually you would start with denying personalization and storage, and then interact with the user to find out their preferences. So it might very well be that your Google tags run with full permissions before you change the status to "denied".
You can check if you have successfully changed the status by inspecting the requests to Google tags in the network tab in the browser. Look for a parameter called "gcs
" - it should have a value of "100
" if the status is denied, and "111
" if the status is granted.
If you have denied storage, the requests will not use cookie data, even when a cookie is present.