IP anonymization with gtag.js

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

For all events

To anonymize the IP address 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 an 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 more about how IP anonymization works, read the IP Anonymization in Google Analytics article in the help center.