google-analyticsgoogle-analytics-apigoogle-analytics-4

Issue with IP Anonymization Using ReactGA


I'm currently using the ReactGA library in a React.js project to implement Google Analytics. 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?

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


Solution

  • For Google Analytics 4 properties, IP anonymization is enabled by default.

    This doesn't mean that you will see the parameter anonymizeIp, but rather that Google does the anonymisation itself behind the scenes without the need for configuration.