Latest updates from CookieScript and the privacy world

News

Hero

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 the GDPR. Under the 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.

IP anonymization was used in the old Universal Analytics. In Google Analytics 4, IP anonymization is no longer necessary since it is enabled by default.

IP anonymization: Google Analytics 4 and Universal Analytics

As of 2025, IP anonymization in Google Analytics is no longer used.

Google used the IP anonymization functionality in the old Universal Analytics, which required manual configuration to enable IP anonymization. Users could manually enable IP anonymization with anonymize_ip: true.

IP anonymization is enabled by default for Google Analytics 4 (GA4) properties. You cannot manually enable or disable it like you could in Universal Analytics.

In Google Analytics 4, IP anonymization is no longer necessary since IP addresses are not logged or stored.

This change in GA4 is part of Google’s aim to align with GDPR and other privacy regulations. By enabling IP anonymization automatically, Google shows its commitment to enhancing user privacy and compliance of Google Analytics with privacy laws.

Use CookieScript CMP to create a cookie banner, collect user consent, and fulfill other requirements to comply with privacy laws.

Why Users Had to 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 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.

Before 2023, when Universal Analytics was still used, if you decided not to use Google Consent Mode and wanted to collect accurate data in Google Analytics, this could be implemented through an IP address anonymization or masking function. Google introduced IP Anonymization in 2010, which enabled to anonymize or mask visitors' IPs before sending them to Universal Analytics. Anonymizing your website visitors' IPs in Universal Analytics allowed achieving GDPR compliance.

How did IP Anonymization Work?

IP anonymization made IP addresses anonymous by setting the last digits of users' IP addresses to zeros. The IP anonymization feature in Google Universal Analytics set 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 was 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 occured before the personal data storage or processing takes place. After the request for IP anonymization, Google Universal Analytics anonymized the IP address as soon as technically possible. The full IP address was never written or being used for data processing.

Please note that, regardless of whether the IP anonymization was enabled, the visitor's IP address was still initially sent to Google's servers. The IP anonymization occured at Google servers before an IP address was saved to disk. Google solved this issue in GA4, where no personal data is sent to Google.

Methods for Implementing IP Anonymization

There were several methods for implementing 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.

Frequently asked questions

Is IP anonymization still used?

No. IP anonymization was used in the old Universal Analytics. In Google Analytics 4, IP anonymization is no longer necessary since it is enabled by default. You cannot manually enable or disable it like you could in Universal Analytics. This was done by Google to comply with the privacy regulations. Use CookieScript CMP to comply with the privacy laws.

Why anonymize IP addresses in Google Analytics?

in Europe, 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 was designed to help website owners coolect data about users and comply with GDPR requirements. Use a privacy policy generator at CookieScript, which automatically updates your Privacy Policy and allows to comply with the GDPR.

How to implement IP anonymization?

There is no need to make any adjustments in GA 4, since IP anonymization is enabled by default. In Universal Analytics, IP anonymization could be implemented with gtag.js, analytics.js, and Google Tag Manager. Use CookieScript CMP to comply with the privacy laws.

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 information. Tracking the IPs of website visitors without their consent in Europe is not GDPR compliant and 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.