codler / react-ga4

React Google Analytics 4
https://www.npmjs.com/package/react-ga4
266 stars 34 forks source link

Issue with IP Anonymization #86

Open jayant-lumino opened 4 weeks ago

jayant-lumino commented 4 weeks ago

My goal is to anonymize IP addresses to comply with GDPR regulations, but I'm having trouble getting it to work correctly.

Here’s the relevant code snippet I'm using:

const googleAnalticsKey = 'G-**********';

ReactGA.initialize(googleAnalticsKey, {
  gaOptions: {
    anonymizeIp: true
  }
});

Even with anonymizeIp set to true, when I inspect the network requests using Chrome Developer Tools, I'm not seeing the aip=1 parameter in the query string, which indicates that IP anonymization isn't being applied.

I’ve also tried using ReactGA.set({ anonymizeIp: true }); after initialization, but the issue persists.

Could you please advise on how to properly enable IP anonymization using ReactGA? Is there something I’m missing, or is there another approach I should consider?

Thanks in advance for your help!

And yes according to this answer it should be enable by default but still it's not working.