Welcome to WebmasterWorld Guest from 54.198.41.76

Forum Moderators: DixonJones & mademetop

Google Analytics: Anonymize IP: How?

Where to make the setting/change

     
5:57 pm on Feb 2, 2018 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member ken_b is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Oct 5, 2001
posts:5850
votes: 102


I found this page:
[developers.google.com...]
about this that says to use this code:
ga('set', 'anonymizeIp', true);

But where do I find/put it?
6:36 pm on Feb 2, 2018 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member ken_b is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Oct 5, 2001
posts:5850
votes: 102


OK so looking at the analytics code on my pages I see a similar command just befor the

ga('send', 'pageview');
</script>

Do I just paste
ga('set', 'anonymizeIp', true);

in there like this?
ga('send', 'pageview');
ga('set', 'anonymizeIp', true);
</script>
6:38 pm on Feb 2, 2018 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month

joined:Sept 25, 2005
posts:1906
votes: 299


In your tracking code, but it depends on your implementation. The ga() function is for analytics.js, the previous implementation (i.e. before gtag.js).

Might as well update your tracking code to gtag.js, while you're at it. Then you'd use something like this:

<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-XXXXXX-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-XXXXXX-1', { 'anonymize_ip': true });
</script>


If you're using analytics.js, you already have something like this:
 ga('create', 'UA-XXXXXX-1', 'auto');
ga('send', 'pageview');

To which you'd add:
ga('set', 'anonymizeIp', true); 
7:05 pm on Feb 2, 2018 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member ken_b is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Oct 5, 2001
posts:5850
votes: 102


Thanks robzilla, that's just what I needed to know.

Much appreciated.