anonIp

We at iubenda - a generator for privacy policies - get asked about Google's _anonymizelp function in ga.js or analytics.js often. This post will teach you what you need to know:


Let's look at the most important facts in our highlight box:

The GA _anonymizeIp function

The Google Analytics _anonymizeIp function anonymizes the last digits of the user's IP. This has some ramifications:

  • If you are located in Germany, your regulators want you to follow the following procedure
  • If you are located anywhere else in Europe, it may be interesting or relevant for you as well, however check with your local data protection authorities what their stance is on the issue
  • You should upgrade the Google Analytics snippet as shown below
  • You should make changes to your privacy policy to highlight that fact
  • It can be easily done with iubenda

What is Google Analytic's _anonymizeIp function?

The _anonymizeIP function takes the end-users IP and sets the last digits to 0, therefore anonymizing the end-user before the processing and storage begins. The IP masking takes place as soon as data is received by the Google Analytics Collection Network (and that is, within Europe). The following are Google's words to explain what exactly is happening:

When a customer of Google Analytics requests IP address anonymization, Google Analytics anonymizes the address as soon as technically feasible at the earliest possible stage of the collection network. The IP anonymization feature in Google Analytics sets the last octet of IPv4 visitor IP addresses and the last 80 bits of IPv6 addresses to zeros in memory shortly after being sent to the Google Analytics Collection Network. The full IP address is never written to disk in this case.

That whole process will also result in a slight reduction of the accuracy of geographic reporting.

Why use Google Analytics's _anonymizeIp?

Google has provided this function since May 2010 to allow website owners to request that all of their visitors' IP addresses are anonymized within Google Analytics. This has been a main issue for Germany's data protection authorities, which is also why German users must make use of the anonymization technique. The following is an outtake from a guide prepared by the data protection office of Hamburg for its citizens:

4. You must use appropriate settings in the Google Analytics program code to instruct
Google to shorten IP addresses. For each web page that incorporates Google
Analytics, the "_anonymizeIp()" function must therefore be added to the tracking
code. Further information can be found in Google's technical instructions at
"http://code.google.com/intl/de/apis/analytics/docs/gaJS/gaJSApi_gat.html#_gat._anonymizeIp".

5. If you have already integrated Google Analytics into your web pages, it must be
assumed that data has been collected unlawfully. This old data must be deleted. As
far as we are aware, the only way to do this is to delete the old Google Analytics
profile and subsequently open a new one. Please note that this may result in you
receiving a different tracking code or web property ID (UA-XXXXX-YY), meaning that you will have to update your web pages accordingly.

Google makes a point that this feature had also been designed to help site owners to comply with their own privacy policies. So if your privacy policy sets out the anonymization of your users' IP addresses, then implement the _anonymizeIp function.

Please note that the above quotes (4. & 5.) are requirements reflecting the applicable legislation in Germany as it stands in March 2013 and may change in the future.

Update March 2015:

google_code_error

Google has updated their documentation and the links to the anonymizeIP help are not hosted on Google Code anymore, they are now to be found at the following addresses:

Analytics.js anonymizeIP Google help

https://developers.google.com/analytics/devguides/collection/analyticsjs/advanced#anonymizeip

GA.js anonymizeIP Google help

https://developers.google.com/analytics/devguides/collection/gajs/methods/gaJSApi_gat#_gat._anonymizeIp

iOS anonymizeIP Google help

https://developers.google.com/analytics/devguides/collection/ios/v3/advanced#anonymizeIp

Android anonymizeIP Google help

https://developers.google.com/analytics/devguides/collection/android/v4/advanced#anonymizeIp

How to use the _anonymizeIp function?

1) Implement the anonymizeIP code:

Attention: the codes below are just examples and need to be adapted to your working site. Most importantly, make sure that the anonymizeIP is set before the pageview.

Traditional GA.js

The _anonymizeIp() function removes the last octet of the IP address prior to its storage. This would be the recommended async snippet that you'll have to implement into your sites:

var _gaq = _gaq || [];
 _gaq.push (['_setAccount', 'UA-XXXXXXX-YY']);
 _gaq.push (['_gat._anonymizeIp']);
 _gaq.push (['_trackPageview']); 

Here's what the whole traditional ga.js snippet might look like

<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try{
var pageTracker = _gat._getTracker("UA-xxxxxx-x");
_gat._anonymizeIp();
pageTracker._trackPageview();
} catch(err) {}</script>

More info regarding the anonymizeIP() function for the older GA.js and the implementation snippets can be found on Google's developer guide.

The more recent Analytics.js

Below you can find the full asynchronous Google Analytics snippet:

<!-- Google Analytics -->
<script async src='//www.google-analytics.com/analytics.js'></script>
<script>
window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;
ga('create', 'UA-XXXX-Y', 'auto');
ga('send', 'pageview');
</script>
<!-- End Google Analytics -->

With Analytics.js you can anonymize the IP addresses for all the hits sent from a page by using the set command and setting theanonymizeIp field to true:

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

The full snippet therefore would look something like this (this is the async snippet with support for preloading from the Google docs):

<!-- Google Analytics -->
<script async src='//www.google-analytics.com/analytics.js'></script>
<script>
window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;
ga('create', 'UA-XXXX-Y', 'auto');
ga('set', 'anonymizeIP', true);
ga('send', 'pageview');
</script>
<!-- End Google Analytics -->

More info regarding the anonymizeIP() function for the recent Analytics.js and the implementation snippets can be found on this Google developer guide.


2) When you've changed your code on the site, it's time to update your privacy policy

Iubenda makes this kind of thing straight forward. Iubenda generates a privacy policy based on the third-party apps you are using (such as Google Analytics) and it has more than 300 pre-written clauses for you. The only thing you need to do, is to use our privacy policy generator that will walk you through the generation of a privacy policy with Google Analytics and anonymized IP wording.

It's easy to keep your privacy policy up to date with iubenda and to add other languages as well.

Let us walk you through it now, make sure to include our clause "Google Analytics with anonymized IP" into your privacy policy. If you are using other languages, look for

  • German: "Google Analytics mit IP-Anonymisierung"
  • French: "Anonymisation IP dans Google Analytics"
  • Spanish: "Google Analytics con dirección IP anonimizada"
  • Italian: "Google Analytics con IP anonimizzato"

Generate a Privacy Policy for your site

Getting started with iubenda for _anonymizeIP

  • Go ahead & use our clause "Google Analytics with anonymized IP"
  • Add any other services you may be using
  • Add the iubenda privacy policy to your site
  • Read the more general Google Analytics Guide

Generate a Privacy Policy with anonymizeIp


Paymill Privacy PolicyPrivacy Policy for 2Checkout.comPrivacy Policy in German?

About Us

Iubenda is the easiest and most professional way to generate a privacy policy for your website, mobile app and facebook app
www.iubenda.com

Generate a privacy policy now

Ready in a few steps and built to meet the needs of both website and mobile app owners

Generate your privacy policy now
RSS FEED

Sometimes the best choice is to "just give it a try"

Iubenda is the easiest and most professional way to generate a privacy policy for your website, mobile app and facebook app

Generate your privacy policy now