Analytics
2.6K members online now
2.6K members online now
Dive into multiple domain (Cross/Sub) tracking, implementing Ecommerce and Enhanced Ecommerce, setting up Event tracking, and Universal Analytics code.
 
Guide Me
star_border
Reply

Visitor IP is not anonymized for Google Analytics

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

Hello Everyone, i newbie here and trying to optimize my site score.. 

i had setup bellow type of analytic code inside my website..

<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-XXXXXX-X', 'auto');
ga('set', 'anonymizeIP', true);
ga('send', 'pageview');
</script>

afterward trying see onpage technically seo, getting this type error " Visitor IP is not anonymized for Google Analytics" 

and one more thing when i'm trying to check inside google page speed my site page score that time getting "

Leverage browser caching" error/warrining.. "

how can i fix both things ?

 

Thanks in advance..

1 Expert replyverified_user

Visitor IP is not anonymized for Google Analytics

Top Contributor
# 2
Top Contributor

You may want to try setting the anonymizeIP field to true when the tracker is created, 
rather than setting it on the tracker after the tracker has been created.

Try the following instead

<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-XXXXXX-X', 'auto', {
anonymizeIp: true
});
ga('send', 'pageview');
</script>

 

 

 

Bronwyn Vourtis, Google Analytics Top Contributor
Was my response helpful? If yes, please mark it as the ‘Best Answer.’ Learn how here