How to disable cookies in GA4?

Viewed 1762

Using GA4 property with (gtag.js) following config:

        gtag('js', new Date());
        gtag('config', 'G-XXXXXXX', {
            client_storage: 'none',
            client_id: clientId, // I generate this
            anonymize_ip: true,
        });

And it still writes _ga and _ga_XXXXXXX cookies.

From what I found the flag client_storage=none only works for the old UA- properties, but for the new G- properties it doesn't have any effect.

3 Answers

The new way when using gtag is:

    gtag("consent", "default", {
      ad_storage: "denied",
      analytics_storage: "denied",
      functionality_storage: "denied",
      personalization_storage: "denied",
      security_storage: "denied"
    });

The first two storage settings are documented here in the tag manager documentation and this support ticket mentions some additional settings that can be denied.

I tested this and it doesn't set a cookie any longer.

Apparently it breaks real-time analytics, but I do see regular data comming in after a day as usual.

The new G- properties it always has the data anonymized by default, so there is no need for the parameter anonymize_ip.

Anonymization tends to be used to assimilate the data from statistical to technical and to be able to track with Google Analytics.

Blocking tracking is not a good practice, inconsistent and unrepresentative data can be collected based on when the user accepts the cookie policy.

That kind of configuration (client_secure) works in UA while in GA4 doesn't work (at least currently). It is still an evolving system.

I have a react project and I call

 ReactGA.gtag('consent', 'default', {
  ad_storage: 'denied',
  analytics_storage: 'denied',
  functionality_storage: 'denied',
  personalization_storage: 'denied',
  security_storage: 'granted',
  wait_for_update: 2000,
})

before the ReactGA.initialize method and it seems there are no cookies in the developer console. I don't see much into this. More context here

EDIT: Even tho the setting remove the cookies, it turned out the GA stopped tracking, so basically nothing worked.. :/

Related