Opinion is divided on whether the new cookie regulations apply to the cookies set by Google Analytics.
If you want to prevent these cookies being set, you need to ensure that the Google Analytics scripts do not run. We have added a status object to our javascript that allows you to do just that.
As an example, you can look at the Google Analytics code for this site (using View Source). For convenience, here is is as well.
<script type="text/javascript">
if (_cookieOK.accepted){
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-222592-4']);
_gaq.push(['_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>
The relevant changes to the stock script are highlighted in red. At the moment the _cookieOK variable only has the accepted property, but we may well add more.
Of course this means that the page views for these users will not be reported to Google Analytics. We are working on a way to do that without setting cookies on the visitor’s machine – stay tuned.