Anonymizing Google Analytics

Anonymizing Google Analytics means altering the IP address of visitors to a website before sending the tracking data to Google, so that the search engines can't directly assign tracking data to an exact IP Address.

Reasons for anonymization

Google Analytics triggers serious concerns with German data protection advocates. The assumption is usually that too much data is being collected with Google Analytics that can be clearly assigned to each user due to their IP address.

Ever since the ECJ judgment of 24 November 2011 (Az. C-70/10) that IP addresses can be regarded as personal data because they allow conclusions about the user, the anonymity of the IP addresses of users has become the basic requirement for legally compliant use of the tracking service.


Duties of the website operator

To use Google Analytics in compliance with legal requirements, site operators must undertake a number of steps:

  • Contract: The experts assume that you have concluded a contract with Google for commissioned data processing according to § 11 BDSG. This should be concluded in writing.
  • Anonymization of IP addresses: If you want to anonymize Google Analytics, the last 8 bits (the last octet) of the IP addresses must be deleted. The Google Analytics code is extended for this purpose with the “anonymizeIP” function.
  • Opposition rights: Each user has the right to disagree with the use of their personal data. To this end, the site operator should provide a link to a deactivation add-on that allows one to prevent data acquisition by Google Analytics, and put the link in the privacy policy on a double opt-out cookie, which excludes the tracker.
  • Privacy statement: Google previously provided an article which informed you about the use of Google Analytics and which was to be integrated in the Privacy Policy. Although it is no longer offered by Google, it is still regarded as the standard.
  • Old data: Existing old data were collected without anonymization and was therefore unlawful. If you want to be on the safe side, you should, in principle, delete old profiles and restart with the evaluations from the date of anonymization.

Altering the IP of visitors

In order for the IP of visitors to be stored in Analytics only in a masked form, the _anonymizeIp () function must applied. The complete (standard) integration of the Google Analytics tracking code will look something like this:

For universal analytics:


(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),

ga('create', 'UA-XXXXXXX-X', '');
ga('set', 'anonymizeIp', true);
ga('send', 'pageview');


The data confirm tracking code for the classical analytics looks like this:

<script type="text/javascript">

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

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);


The old tracking method still allows the use of Google Analytics, but it is limited. Google therefore recommends the implementation of new codes.

Every extension with the extra anonymize_IP ensures that IP data is no longer completely stored by Google. Although they are first delivered for the purpose of evaluation to Google Analytics unmasked, they are anonymized directly before the saving process and then stored.

The anonymization of the IP address is also possible with the Google Tag Manager. Either a complete tracking code including the extra anonymize-IP will be integrated there, or a variable will be established which finds a use for every used tracking code.

Consequences of unencrypted transmission of the IP address

If web site operators do not prevent the transmission of the complete IP address to Google, they theoretically violate applicable law and can therefore risk a warning notice.