Since 1998

How to exclude your own traffic from Google Analytics stats

A few months ago I wrote an article slamming Google Analytics’ serious shortcomings.  I can afford to, because at that level of fame, those people have a duty to deliver stuff that works, not just stuff that looks good.  In particular, I raised a crucial point about statistics: how to exclude your own actions from Google Analytics reporting.  Many of us don’t have a fixed IP, or check GA from other machines, not necessarily known in advance, and it was high time we had a procedure that works whatever the context.  The method I propose here works for me.  I’d love some feedback to know whether it works for you too.
Defining the right filter to exclude your own traffic from Google Analytics isn't trivial.

The background

For the results to be usable, once the testing phase is over, your own traffic obviously must not end up in the Google Analytics (GA) statistics, whether real time or asynchronous.  To allow this, GA lets you define exclusion filters.  Some will say“just exclude your IP”; fine for fixed IPs, but that’s not my case.  Besides, even for users on a fixed IP, nothing says they won’t want to check their GA stats from another machine, not yet defined in the filter list, or whose IP isn’t fixed, etc.
So I rule out using a fixed IP.  From there, a more professional way to get excluded would be to carry a specific cookie, but it isn’t among the built-in filters, and it needs a bit of coding to set up, which makes it hard to use for non-technical users.  That’s when I had decided to use a language exclusion filter, so as to add an exotic language to my preferred languages, like Zulu, otherwise rare on the Internet.

The method

In the article Google Analytics reporting is incomplete and broken I described why the exotic language trick isn’t quite acceptable.  So I went for the browser version trick, i.e.  giving your browser a custom signature, and defining a filter in Google Analytics that will exclude from the stats any action performed by such a browser.

Signature?

The approach here is to find what could identify you, uniquely, as opposed to another user of your website who would have the same configuration as you.  If you use a browser with a default configuration to connect to your site, it’s entirely conceivable that another user could have the same settings to connect to it, which makes telling them and you apart impossible.  So we’ll customise your browser by giving it a signature, just like you have yours, and it identifies you uniquely enough to be used day to day.
A browser’s signature has existed since the dawn of time . . .   Internet time.  It’s an HTTP header identifying the model, version number, operating system and other things it’s important to declare to the website.  This HTTP header is called User-Agent.  Handy: Google Analytics has a predefined filter, ’Browser version’, and it’s the same thing.

How to customise the signature is specific to each browser.  I’ll keep it simple; since I don’t know which browser you use, I’ll describe how to customise Firefox (FF), so we’re talking about the same thing.  In Firefox it’s easy to define any custom setting.  And let’s face it, whatever your favourite browser, you can perfectly well pick FF as the browser you’ll use to test your sites under Google Analytics’ watch, after all.

Step 1: find your User Agent

There are several ways to find it (FireBug, web log, network analyser, $_SERVER[’HTTP_USER_AGENT’]), and if none of that rings a bell, or you don’t have time to play the nerd, you can simply click what’s my user agent?

Let’s say you find Mozilla/5.0 (Windows NT 6.1; WOW64; rv:19.0) Gecko/20100101 Firefox/19.0 FirePHP/0.7.1

Step 2: define a custom version of the User Agent in Firefox.

  • In the address bar, go to the special URL about:config, and click ok on the warning.
  • Right-click in the body of the page, and create a new string value, named general.useragent.override, whose value is the one you found in step 1, followed by an imaginary module of your own, slash, its version number.  For example, the full value could be Mozilla/5.0 (Windows NT 6.1; WOW64; rv:19.0) Gecko/20100101 Firefox/19.0 FirePHP/0.7.1 Onsecalmecmoi/1.0
    For those who didn’t quite get it, I added at the end of the existing signature the imaginary module/version "on se calme, c’est moi" ("calm down, it’s me"), version 1.0, written without spaces or apostrophes, as I don’t know which characters are allowed, so I kept it simple.
From then on, every new connection with Firefox will send a User-Agent HTTP header with this key’s value.  This lets the server you connect to identify the make and model of your client browser, and so provide the best service for that client . . .   the best service which, for the purpose of this article, is precisely to ignore you.

Step 3: how to get Google Analytics to ignore you?

Here is an example of a filter that could ignore your own actions.
Starting assumption: you have a GA account with at least one profile describing the URL to monitor.
  • In the GA admin panel, go to the profile(s) you want to be ignored by.
  • Go to the Filters tab of each profile
  • Add a new custom exclusion filter on the browser version field, and enter“Onsecalmecmoi” as the filter expression
  • Save
From now on, your browsing should no longer appear in real-time and asynchronous visits.  I tested it with two browsers, one, FF, set up with this string, and the other not, and indeed I got the expected result.

17 May 2013: latest update about this step 3

I repeated this test a few days ago, watching the real-time visits graph: in the seconds after setting the filter, I still saw my hits appear as bars scrolling from right to left in the timeline.  So I’m leaving some questions open: is there a delay before this filter takes effect? What exactly does ’Browser version’ mean? Is it the main keyword on the far left of the User-Agent string (e.g.  Mozilla), or is the whole User-Agent string checked, right to its very end? Finally, what is the valid regular expression syntax in the value field? Should you put .* before and after? I’ll look into these points next time I revisit this article.

(3501 views)
created Sunday 03 March 2013
revised Monday 02 November 2026 by
Would you accept our confidentiality policy? It is about cookies and personal data...