There has been some confusion about the implementation of the new anonymizeIP functionality of Google Analytics with the new asynchronous tracking snippet. In Google Analytics, anonymizeIP() can be used to anonymize the IP of a visitor to a site. It does so by removing the last octet of the IP address before it gets stored. This functionality addresses some privacy concerns that were raised in the past.
To make this work with the asynchronous tracking snippet your code should look like this:
<script type=”text/javascript”>
var _gaq = _gaq || [];
_gaq.push(
['_setAccount', 'UA-xxxxxxxx-x'],
['_gat._anonymizeIp'],
['_trackPageview']
);
(function() {
var ga = document.createElement(‘script’); ga.type = ‘text/javascript’; ga.async = true;
ga.src = (‘https:’ == document.location.protocol ? ‘https://ssl’ : ‘http://www’) + ‘.google-analytics.com/ga.js’;
var s = document.getElementsByTagName(‘script’)[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
Some testing on this site has shown that this implementation works and will anonymize the IP’s of the visitors to your site.