IP anonymization with gtag.js

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

For all events

To anonymize IP addresses for all events, update the config for your property by setting the value of the anonymize_ip parameter to true:

gtag('config', '<GA_TRACKING_ID>', { 'anonymize_ip': true });

For a single event

To anonymize the IP address for a single event, set the anonymize_ip parameter in the parameters object:

gtag('event', 'your_event', { 'anonymize_ip': true });

Learn more

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