In my last post I wrote that I followed some instructions to
exclude myself from Google Analytics’ reports on my Octopress blog. There was an error in the
Javascript that was preventing the required cookie from being set. Here’s what I did
that finally worked:
The instructions that I found in Google’s support forum
correctly show how to set a filter to exclude any requests where the client has a custom cookie set.
However, the javascript code that’s supposed to generate the cookie gave me a ‘variable not defined’ error.
This page
had the instructions that worked for me. For completeness, here’s the current version of the HTML file
I use to exclude myself from the reports:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><htmlxmlns="http://www.w3.org/1999/xhtml"><head><metahttp-equiv="content-type"content="text/html;charset=iso-8859-1"/><title>Excluded from Google Analytics</title><script type="text/javascript">var_gaq=_gaq||[];_gaq.push(['_setAccount','UA-XXXXXXXX-X']);_gaq.push(['_trackPageview']);_gaq.push(['_setVar','excludeMePlease']);(function(){varga=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';vars=document.getElementsByTagName('script')[0];s.parentNode.insertBefore(ga,s);})();</script></head><body> You have been excluded from Google Analytics.
</body></html>
Essentially, I moved the line that sets the cookie from the body tag to line 11.