Latest News, Updates, Tutorials and much more

Blog

IP anonymization in Google Analytics

Google Analytics monitors website visitors' activities and informs businesses about their customers. In Europe, the end-users have a right to data privacy through GDPR. Under GDPR, an IP address is considered personal data. The solution to collect website visitors' data without violating legal requirements could be implemented through an IP address anonymization function. IP anonymization sets the last digits of users' IP addresses to zeros, so the website visitor's IP address is made anonymous.

Why anonymize IP addresses in Google Analytics?

E-shops and other businesses need to monitor their website traffic as closely as possible in order to understand the website visitors' behavior and various trends that can shape their business. Google Analytics is the industry leader for tracking and analyzing individual visitor activities on a website in a detailed manner. The various data offered up by Google Analytics can inform businesses about their customers in great detail. Businesses can essentially track visitors’ journeys through their sites in real-time and can shape marketing decisions.

However, in Europe, the end-users have a right to data privacy through GDPR. The users have the right to decide which personal information they want to give up to marketers and advertisers. Under GDPR, an IP address is Personally Identifiable Information, which is considered personal data. Therefore, businesses must obtain website visitors’ consent before running any type of cookie which collects the IP address. The easiest option to comply with the latest privacy regulations according to GDPR is to use Google Consent Mode. However, this could result in inaccurate data collection in Google Analytics.

If you decide not to use Google Consent Mode and want to collect accurate data in Google Analytics, this could be implemented through an IP address anonymization or masking function. Starting from 2010, Google Analytics introduced a function, called IP Anonymization, which enables to anonymize or mask visitors' IPs before sending them to Google Analytics. Anonymizing your website visitors' IPs allows achieving GDPR compliance.

Thus, implementing IP anonymization allows to achieve GDPR compliance and to collect accurate data in Google Analytics at the same time. CookieScript offers consent management and the IP anonymization function for the clients, complying with the latest privacy laws worldwide and alloying to collect visitors data in Google Analytics:

How does IP anonymization work?

The IP anonymization feature in Google Analytics sets the last octet of IPv4 user IP addresses and the last 80 bits of IPv6 addresses to zeros in memory shortly after being sent to the Analytics Collection Network. For example, an IP address of 12.214.31.144 would be changed to 12.214.31.0 In this case the website visitor's IP address is made anonymous. In case, the IP address is an IPv6 address, the last 80 of the 128 bits would be set to zero.

IP anonymization Google Analytics scheme

Geographic data later could be obtained from anonymized IP addresses.

The IP anonymization occurs before the personal data storage or processing takes place. After the request for IP anonymization, Google Analytics anonymizes the IP address as soon as technically possible. The full IP address is never written or being used for data processing.

Please note that, regardless of whether the IP anonymization is enabled, the visitor's IP address is still initially sent to Google's servers. The IP anonymization occurs at Google servers before an IP address is saved to disk. To avoid sending any data to Google, the Google Analytics should be removed entirely.

The ways to implement IP anonymization:

IP anonymization with gtag.js

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', 'UA-XXXXXXXXX', { 'anonymize_ip': true });

This has to be done during initial initialization, not as a separate line of code.

IP anonymization with analytics.js

Add this code before sending a first pageview:

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

IP anonymization with Google Tag Manager

Step 1: Add Google Analytics (Universal Analytics) tag if not added yet. 

ip anonymization tagmanager 1

Step 2: In tag configuration mark Enable overriding settings in this tag, go to More Settings > Fields to Set > +Add field > Select anonymize.

ip anonymization tagmanager 2

Step 3: Fill in true in the Value field: 

ip anonymization tagmanager 3

Step 4: Click Save to save your changes and then Submit to publish them.

IP anonymization with GA 4

There is no need to make any adjustments in GA 4, IP anonymization is enabled by default.

Frequently asked questions

Why anonymize IP addresses in Google Analytics?

 in Europe, the end-users have a right to data privacy through GDPR. The users have the right to decide which personal information they want to give up to marketers and advertisers. Under GDPR, an IP address is considered personal data. Therefore, the IP anonymization is designed to help website owners comply with GDPR requirements since the IP address is considered personal data. Use a privacy policy generator at CookieScript, which automatically updates your privacy policy.

How to implement IP anonymization?

IP anonymization could be implemented with gtag.js, analytics.js, and Google Tag Manager. There is no need to make any adjustments in GA 4, since IP anonymization is enabled by default. Please see the step-by-step guide on how to anonymize IP addresses on Google Analytics. 

How to use IP anonymization properly?

First, you have to change the Google Analytics code on your website according to the step-by-step instruction. Second, to comply with the GDPR requirements after the IP anonymization is set up, you need to update your privacy policy.

Is IP tracking GDPR compliant?

Under GDPR, IP addresses are considered personal data. Tracking the IPs of website visitors without their consent in Europe could lead to legal consequences under the rules of GDPR. Use a privacy policy generator at CookieScript, which automatically updates your privacy policy according to recent changes in legal requirements.

What data does my IP address show?

The IP address reveals the geolocation of the device, such as the city, ZIP code, area code, and your Internet Service Provider name. Use a privacy policy generator at CookieScript, which automatically updates your privacy policy according to recent changes in legal requirements.

How to find my IP for Google Analytics?

The simplest way to find a public IP address you are currently using is to search "what is my ip address" on google.com. If you want to create a professional Privacy Policy for your business or website, use a privacy policy generator at CookieScript, which automatically updates your privacy policy according to recent changes in legal requirements.

New to CookieScript?

CookieScript helps to make the website ePrivacy and GDPR compliant.

We have all the necessary tools to comply with the latest privacy policy regulations: third-party script management, consent recording, monthly website scans, automatic cookie categorization, cookie declaration automatic update, translations to 34 languages, and much more.