React-ga: Disable react-ga after initialization (GDPR)

Created on 12 Aug 2019  路  4Comments  路  Source: react-ga/react-ga

Due to GDPR, I have to provide a way for users to withdraw their cookie consent. So I'm wondering is there a way to disable react-ga after initializing it?

The solution mentioned in #271 is to postpone calling initialize(). But here I'd like to disable it after calling initialize(). Now I have a workaround to set a flag and check that flag every time before sending a GA event.

Most helpful comment

All 4 comments

I too am wondering about this. My plan is to try manually expiring the cookies using the 'universal-cookie' library.

import Cookies from 'universal-cookie';
Cookies.remove('_ga');
Cookies.remove('_gat');
Cookies.remove('_gid');

@romiem Did you end up implementing your solution using universal-cookie? Or did you have extra tasks to perform?

@romiem Did you end up implementing your solution using universal-cookie? Or did you have extra tasks to perform?

Yes I did end up using universal-cookie (don鈥檛 forget to set the path and domain options when calling the remove method).

I鈥檓 not sure if it is perfect solution, as I assume react-ga has still loaded the google analytics script into the page and who knows what it is doing under the hood. That said, this solution feels like it is better than doing nothing.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

horaceleung picture horaceleung  路  6Comments

amcinerneynewf picture amcinerneynewf  路  4Comments

velchevski picture velchevski  路  3Comments

dirtyredz picture dirtyredz  路  7Comments

donaldpipowitch picture donaldpipowitch  路  4Comments