There are currently two types of Google Analytics, the normal universal Google Analytics (GA) and Google Analytics 4 (GA4).
GA4 makes the IP addresses of visitors anonymous without having to change anything to the settings. With GA, this is not the case, and an additional piece of code must be added to the tracking code if you’re not tracking via Google Tag Manager.
A tracking code from GA looks like this:
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id='UA-XXXXXXX-X'"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-XXXXXXX-X');
</script>
This is the code that needs to be added to the website. In the above code the tracking ID has been made anonymous so do not use the above code but follow the next steps.
Follow the next steps to make Google Analytics Universal anonymize IP addresses. You need to do this in order to be GDPR proof, you don’t have to put Google Analytics Universal behind a cookie wall if use this technique.
An example of the tracking code includes anonymizing the IP of the visitors.
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id='UA-XXXXXXX-X'"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-XXXXXXX-X');
gtag('config', 'GA_TRACKING_ID', { 'anonymize_ip': true });
</script>
A small side note, by doing this, your own IP address will also no longer be filtered by Google Analytics Universal. This can be annoying for customers, but otherwise, Google Analytics must get behind a cookie. You might also be interested in how to anonymize Hotjar tracking, so you can still track the user behavior without having to put Hotjar behind a cookie wall, or how to add scroll depth tracking via Google Tag Manager to your website.
Working remotely from Groningen, the Netherlands. Get in touch and let’s schedule a meeting, no strings attached.
Get in touch