How to enable IP Anonymization in Google Analytics

Now with GDPR is better to anonymize (hide) the IP of your visitors.

Here it is one easy way in case you use the newer gtag.js from Google Analytics in your website.

Add after Google Analytics ID:
{ 'anonymize_ip': true }

 

So the script it will look like this:
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=GA_TRACKING_ID"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'GA_TRACKING_ID', { 'anonymize_ip': true });
</script>

Source: https://developers.google.com/analytics/devguides/collection/gtagjs/ip-anonymization

  • Was this Helpful ?
  • YesNo