Cookies are getting set before consent

2.2k Views Asked by At

I was trying to integrate cookieyes GDPR solution to a WP website. Below is the code for GTM and coookieyes that are added in the website. But the cookies

( _ga , _gid and gat_gtag_UA_xxxxxxxxxxx_1)

are getting set even if the accept button is not clicked.

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

There are 2 best solutions below

0
Safwana On BEST ANSWER

To block the GTM cookies using CookieYes, what you need to do is add the data attribute 'data-cookieyes' to the GTM script tag. Set the value of the attribute to corresponding ( 'cookieyes-{category-name}' ) category.

For example, as the GTM script belongs to "Analytics" category, the value will be 'cookieyes-analytics'. In this case, to block the code prior-consent, change the GTM script tag as:

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

This has been explained in detail here, How to Implement Prior Consent Using CookieYes.

0
Vykintas On

All set cookies is from Google analytics.

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

Should stop them.

For more details read:

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