如何检查我的 google 许可实施是否有效? (标签管理器,网站)

How can I check whether my google consent implementation works? (tag manager, website)

我们正在使用 Google Analytics consent mode (Beta). I believe my implementation is correct, following the official documentation。但是,无论我选择加入还是选择退出跟踪,我都看不到(在 GTM“预览模式”下)行为的差异。在这两种情况下,标签都会被触发并标记为“成功”。我想知道我的实施是否有效。 (当然我会在测试会话之间清除 cookie 和缓存)

如果同意被拒绝,我应该看到或不应该看到什么?我应该看到有什么区别可以告诉我是否考虑了同意?我如何判断 GTM 是否在跟踪?

有关信息,我的实现:

<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",
    });

额外问题:我的设置是否默认为“授予”,后来更新为“拒绝”受支持的案例?这可能是我看到我的标签一直被触发的原因吗?

无论状态是授予还是拒绝,您都会看到请求 - 事实上,这就是同意模式的要点,允许收集数据,即使用户反对创建个人标识符。

您不应该看到的是正在创建 cookie。但是您的设置有点不寻常,因为您最初将状态设置为已授予。通常你会从拒绝个性化和存储开始,然后与用户交互以找出他们的偏好。因此,在您将状态更改为“拒绝”之前,您的 Google 标记 运行 很可能具有完全权限。

您可以通过在浏览器的网络选项卡中检查对 Google 标签的请求来检查您是否已成功更改状态。查找名为“gcs”的参数 - 如果状态被拒绝,它的值应该为“100”,如果状态被授予,它的值应该为“111”。

如果您拒绝存储,即使存在 cookie,请求也不会使用 cookie 数据。