August 23, 2016 at 12:58 pm
Hello,
I have to anonymize visitors IP address. I know how to do it with Google Analytics code, just inserting this “ga(‘set’, ‘anonymizeIp’, true);” in the snippet.
I need to past the entire code into the theme, so I guess unfortunately I cannot use the dedicated field Google Analytics Tracking ID (appearance – advanced setting).
So, I guess I should paste the entire GA code into the header.php. Now, my header.php looks like this:
<?php
/*
Empty on purpose.
– Force plugins to stop stating incorrect errors –
wp_head();
*/
?>
<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’,’*Login to see link
ga(‘create’, ‘UA-XXXXXX’, ‘auto’);
ga(‘set’, ‘anonymizeIp’, true);
ga(‘send’, ‘pageview’);
</script>
</head>
Is this location OK? Should I change something in this editor?
Thanks a lot
Enrico