What is IP anonymization or IP masking?
Internet Protocol (IP) address anonymization or masking involves obscuring a website visitor's IP address. Anonymization is often used to enhance user privacy in data collection practices like website analytics. Google Analytics is a common use case for anonymization.
For instance, before sending to Google Analytics servers, the last octet of the IPv4 address or the last 80 bits of the IPv6 address can be deleted or masked in such a way that the IP address can no longer be attributed to a specific user.
IP address anonymization occurs before any visitor's data is stored or processed. For instance, for the newest version of Google Analytics 4, IP address anonymization is enabled by default and no manual action is required. For older versions, IP address anonymization is an opt-in feature that requires explicit addition of a parameter to your tracking code.
How to enable IP anonymization in Google Analytics
The process of IP address anonymization takes place within two steps in the collection pipeline: the JavaScript Tag and Collection network:
IP address anonymization with analytics.js
:
ga('set', 'anonymizeIp', true);
IP address anonymization with gtag.js
:
gtag('config', '<GA_MEASUREMENT_ID>', { 'anonymize_ip': true });
IP anonymization can also be set through Google Tag Manager (GTM) graphical settings interface.
IP anonymization for iOS is done automatically with the use of Firebase SDK
or with the following line when using iOS SDK
:
[tracker set:kGAIAnonymizeIp value:@"1"];
IP anonymization for Android is done with Google Analytics Services SDK for Android
with the following configuration parameter:
<string name="ga_anonymizeIp">true</string>