admin管理员组文章数量:1429243
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, // fortable 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?
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, // fortable 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?
Share Improve this question edited Nov 11, 2021 at 9:45 Offirmo asked Nov 10, 2021 at 9:37 OffirmoOffirmo 19.9k13 gold badges81 silver badges99 bronze badges1 Answer
Reset to default 6You 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.
本文标签:
版权声明:本文标题:javascript - How can I check whether my google consent implementation works? (tag manager, website) - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745501641a2661058.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论