IP anonymization with gtag.js – Google Analytics

Posted on May 21, 2018 at 9:40 pm

You can anonymize user’s IP with Global site tag (gtag.js) 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>

This code indicates the user’s IP is anonymized:

'anonymize_ip': true

Make sure to replace GA_TRACKING_ID with your Google Analytics ID.

Read more info here:

IP anonymization with gtag.js

Receive updates via email

Other Posts

Updated Posts