Setting an Exclusion Cookie for Google Analytics with a Bookmarklet

I have been doing a lot of work on my reading software website recently. This has played havoc with my Google Analytics reports.

So I set about looking for a way to block my own hits from the results. Having done a good search for up to date techniques, it seems that a cookie and a filter in analytics are still the current standard.

I came across loads of articles explaining all this, but none were really clear, so I thought I might cover the subject again. Partly for those who follow after me, and partly so I never need to research this again.

So for posterity here’s how to go about it.

Creating the Exclude Filter

I have written a seperate post on how to add an Exclusion Filter to Analytics in 10 easy steps with loads of screenshots.

How to add an Exclusion Filter to Analytics in 10 steps

 

Creating the Cookie

Rather than go down the route of having to install something onto my website, I decided to create a BookMarkLet to generate the exclusion cookie.

This means I can use it for any site, it is quick and simple to use and most importantly there is no need to install anything on the website itself.

Another benefit is that I can get anyone working on or reviewing my site to use it as well, without too much trouble. All in all, a win-win solution to the problem.

Get the BookMarkLet: Drag this link to your browser bar (add it to your bookmarks)
GA IgnoreMyHits

Then to put the cookie in place:

  • Go to the site you want to stop recording hits on
  • Click on the bookmarklet(above) you have stored
    • let it add the exclusion cookie to your browser.

First : choose you exclusion cookie name…

alert1

Then: Make sure it all worked. It will recognise your analytics install and tell you which one it detected.

alert2

 

If, like me, you use differant browsers for testing, make sure you do this with all of your browser,s rather than just your main one. This will ensure that your analytics results are totally accurate.

The only thing you must ensure is that you use the same name for both the cookie and the exclusion filter in analytics.

 

So there you go a nice quick simple solution for clearing up your Analytics results.

I would like to thank, Justin Cutroni , as his blog was the first clear explanation I encountered.

 

A shameless plug..

Bring the benefits of over 15 years experience in internet technologies, from programming through to usability & design, persuasive copy-writing and site speed optimizations.
Check out my consulting company, Technical Magic.

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • Reddit
  • Slashdot
  • StumbleUpon

8 Responses to “Setting an Exclusion Cookie for Google Analytics with a Bookmarklet”

  1. 10 easy steps to add an exclusion filter in Google Analytics Says:

    [...] onDOMLoad: Faster javascript for faster pages with a cross browser version of DOMContentLoaded Setting an Exclusion Cookie for Google Analytics with a Bookmarklet Jul [...]

  2. Justin Cutroni Says:

    Thanks for the plug. I’m glad you found the post helpful. I was looking through your site and something caught my eye; your onDOMLoad.js. I don’t know too much JS, just enough to be dangerous :) It appears that your onDomLoad script helps DOM functions load faster.

    I’ve got a small script that loops over all the anchor tags in a page when the page loads and modifies the onClick event. Is it possible that onDOMLoad.js could help speed up that profile?

    Please feel free to send me a PM to discuss.

    Thanks!

    Justin

  3. Techmale Says:

    Thanks Justin, we are all already using the bookmarklet to block our hits from analytics, so it has been really useful.

    My quick answer to you question is yes, onDOMLoad will speed up your javascript.

    In a litle more detail….
    Any modification to the DOM (ie: links) must be done after the DOM (HTML) has fully loaded, or it will cause an error.

    To do this most people use the onload function of the document, but this waits for the entire page to load, and if you have loads of graphics, this could be quite a few seconds. In other words, you are waiting far longer than you need to.

    Firefox/Mozilla does has an DOMContentLoaded event, but is the only brrowser to currently support it, so unless you can specify the browser people use, you can never rely on it.

    onDOMLoad providing a stable cross-browser event model that solves this timing problem. It allows you to run your functions as soon as the DOM/HTML has loaded. It also provides a stable fall back position if the brower is truely antiquated.

    There is the cost of loading the onDOMLoaded script itself, but this is more than offset by the speed increase in you page as you can launch your functions seconds earlier, and both page function and improve user experience.

  4. Tim Says:

    Hi Justin,
    This bookmarklet seems the easiest way to go.
    How do I confirm that the cookie has been installed? Thanks.

  5. Techmale Says:

    @Tim: if you are using Firefox, then the easiest way is using the Web Developer Toolabar by Chris Pederick. Simply select Cookies>>ViewCookieInformation, and scroll through the cookies that are displayed. You are looking for _utmv.

  6. Robbin Steif Says:

    Hi Techmale, I am finally cleaning out my email and finally loaded your bookmarklet. It is not that helpful for FF (because I can do it with JS there, not that I know much js, I am a copy and paste lady), but it is wonderful for Safari. Just want to point out that loading a web developer toolbar is a lot to do just to see cookies, how about (in FF), just Tools > Options >Privacy >Show cookies and search for either the site name or as you correctly point out, utmv.

  7. Techmale Says:

    @Robbin: I totally agree with you, in fact, I found doing that in the Web Developer Toolbar was more than I wanted, especially when I am doing repeated cookie work… So, I went and created another Bookmarklet tool, this time just creating a simple DIV lists all the cookies on the page. I had no idea anyone else would appreciate it, so it is currently sitting on my browser at home… I will upload it in a new post when I get home this evening, so you can have a look.

    For anyone else reading this, I should explain, that a Bookmarklet tool script is a small piece of JavaScript, so it can be installed and run on any browser.

    In fact, if you create a your own bookmark bar, and fill it with bookmarklets, you can create you own powerful toolbar like the Web Developer Toolbar.

    I really like the functional programming capabilities of JavaScipt. It means that even though you are limited to 2000 odd characters for a bookmarklet (ie: the max size of a URL), you can compress a huge functionality into the available space.

    If you want to play arround with JavaScript, I would definetely suggest you go and have a look at JSTR

    If anyone is interested, I am quite happy to post and explain each of the 35 odd tools I have created for my own work.

  8. Yi Says:

    Great job! This works with google pages. However, don’t work with google sites. It seems it’s really hard to make cookie in google sites analytics. In google sites, you can not use the script method either. Its analytics is integrated in some other way …

Leave a Reply

Byting the hand that feeds you…