For people who like to make things

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:

exclude.txt download
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
    <title>Excluded from Google Analytics</title>
    <script type="text/javascript">
      var _gaq = _gaq || [];
      _gaq.push(['_setAccount', 'UA-XXXXXXXX-X']);
      _gaq.push(['_setVar', 'excludeMePlease']);
      (function() {
        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '';
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
    You have been excluded from Google Analytics.

Essentially, I moved the line that sets the cookie from the body tag to line 11.