Closed bobapple closed 2 years ago
Hi @bobapple.
In GA4, you must explicitly “tell” the gtag
function to disable cookies/tracking when the user opts-out of a specific category, as shown in the demo example:
https://github.com/orestbida/cookieconsent/blob/49fbcc9a1fbf3ddd25c0f0af6963ac26dc9a9c13/demo/demo_gtm/cookieconsent-init.js#L47-L56
Thank you @orestbida! Totally missed that part in de documentation.
I'm using Google Analytics 4 with
autoclear_cookies: true
. GA4 creates two cookies:_ga
and_ga_XXXXXXXXXX
. It seems to me that autoclear correctly removes both cookies if the user revokes consent for theanalytics
cookiecategory. However, the_ga_XXXXXXXXXX
is recreated after page reload. I believe it's being recreated because in some cases I can see the cookie disapear even without reloading the page.How to reproduce:
0. Keep the browsers developer tools open at any time to see the changes 1. Accept all cookies
_ga
and_ga_XXXXXXXXXX
are createdcc_cookie
has the value{"level":["necessary","analytics"],"revision":0,"data":null,"rfc_cookie":false}
2. Open cookie settings and remove consent for the
analytics
category 3. Save changes 4. Reload page_ga
is gone_ga_XXXXXXXXXX
is still there, however with a different value and expirationcc_cookie
has the correct value (withoutanalytics
), but still let's the_ga_XXXXXXXXXX
throughSample Config
```Cookie Consent test
```