samvermette.com

JUL 29, 2010

Keeping your own traffic off Google Analytics

If you’re like me, the final step before going live with a new website is to add the Google Analytics tracking code snippet. From there on, every visit gets logged. Even yours. This usually flaws your statistics, as you might spend a lot of time testing stuff and making sure everything looks good.

So I’ve been looking for ways to keep your own traffic off Google Analytics. I’ve been successfully using this solution for a while now, but I keep going back for the code snippets. Although it’s an excellent tutorial, I really thought it could be easier. So let’s cut the crap:

Assigning a unique word to your device and domain

Go to your website homepage and copy-paste the following code in your address bar. Feel free to replace macbook with any unique word of your choosing (I like it to be the device name I wish to exclude).

javascript:void(function(w){try{_gaq._getAsyncTracker()._setVar(w)}catch(e){try{__utmSetVar(w)}catch(e){pageTracker._setVar(w)}}alert(w)}('macbook'));void(0);

Hit return and you should get prompted with your new unique word:

Tell Google Analytics to exclude that traffic

In Analytics, hit the Filter Manager and create a new filter:

Make sure your website profile is in the selected column.

That’s it!

All visits to this domain using your current device should now be excluded from Google Analytics. Remember: that unique word is only valid for this device (computer, iPad, iPhone, whatever) and domain. Repeat the process for every device and domain you wish to exclude your own traffic from.

Verifying unique words

Enter the following code in the address bar and hit return. You should be prompted with the current domain/device unique word.

javascript:alert((/__utmv=.+?\.(.*?)(;|$)/.test(''+document.cookie))?RegExp.$1:'No unique word');void(0);

If no unique word has been set, you’ll get the following:


hello@samvermette.com