IP Anonymization

In some cases, you might need to anonymize the IP address of the hit sent to Google Analytics.

For all hits

To anonymize the IP address for all hits sent from a single tracker, you can set the anonymizeIp field to true when you create the tracker.

ga('create', 'UA-XXXXX-Y', 'auto', {
  anonymizeIp: true
});

Or, to set it on the tracker after the tracker is created, use the set command:

ga('set', 'anonymizeIp', true);

For a single hit

To anonymize the IP address of an individual hit, you can set the anonymizeIp field in the fields object for that hit:

ga('send', 'pageview', {
  'anonymizeIp': true
});

Learn more

To learn more about how IP anonymization works, read the IP Anonymization in Google Analytics article in the help center.