IP masking with gtag.js

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

For all events

To mask 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_MEASUREMENT_ID>', { 'anonymize_ip': true });

For a single event

To mask 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 masking works, read the [UA] IP masking in Universal Analytics article in the help center.