在同意之前设置 Cookie

Cookies are getting set before consent

我试图将 cookieyes GDPR 解决方案集成到 WP 网站。以下是网站中添加的 GTM 和 coookieyes 的代码。但是饼干

( _ga , _gid and gat_gtag_UA_xxxxxxxxxxx_1)

即使未单击接受按钮,也会设置。

<?php wp_head(); ?>
</head>
<!-- Start cookieyes banner -->
<script id="cookieyes" type="text/javascript" src="https://app.cookieyes.com/client_data/714e8fa9e198d23xxxxxxxxxx.js"></script>
<!-- End cookieyes banner --> 
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-xxxxxxxxx-1" ></script>
<script>
    window.dataLayer = window.dataLayer || [];
    function gtag() {
        dataLayer.push(arguments);
    }
    gtag('js', new Date());
    gtag('config', 'UA-xxxxxxxxx-1');
</script>

所有设置的 cookie 来自 Google 分析。

ga('create', 'UA-XXXXX-Y', {  'storage': 'none'});

应该阻止他们。

有关详细信息,请阅读:

https://developers.google.com/analytics/devguides/collection/analyticsjs/cookies-user-id#disabling_cookies

要使用 Cookie 来阻止 GTM cookie 是的,您需要做的是将数据属性 'data-cookieyes' 添加到 GTM 脚本标签中。 将属性的值设置为相应的 ( 'cookieyes-{category-name}' ) 类别。

例如,由于 GTM 脚本属于 "Analytics" 类别,因此该值将为 'cookieyes-analytics'。 在这种情况下,要事先同意阻止代码,请将 GTM 脚本标记更改为:

<script async data-cookieyes="cookieyes-analytics" src="https://www.googletagmanager.com/gtag/js?id=UA-xxxxxxxxx-1" ></script>
<script>
   window.dataLayer = window.dataLayer || [];
   function gtag() {
       dataLayer.push(arguments);
   }
   gtag('js', new Date());
   gtag('config', 'UA-xxxxxxxxx-1');
</script>

这里已经详细解释过了,How to Implement Prior Consent Using CookieYes