A Little Background
If you’ve got a website, you’re probably interested in who visits it, where they come from, how long they stay, what pages they look at, etc. You’re not alone. It’s one of the most important things you can do to guarantee that your website accomplishes its goal, whatever that goal may be. There’s nothing more powerful than being armed with information when it comes to all aspects of designing, executing, and managing a web presence, and your website’s analytics is the most powerful weapon in your arsenal.
Perhaps the best known, and most widely used tool in the analytics war is Google Analytics. This indispensable, free tool provides near-realtime feedback on your site and its audience. The implementation of Google Analytics is fairly straightforward. You get yourself a Google Account (and really, at this point, who doesn’t have a Google Account?), you register your site, insert a bit of code they provide you into each page you want tracked, and viola! You’re collecting important, valuable information on people who visit your site!
“But waitaminute,” you’re saying, “don’t I visit my own site?”
Why, yes. Yes you do, and therein lies the problem we’re about to solve for you.
The code you drop into your website doesn’t really know who you are. It doesn’t know that you’d like to track everyone who visits your site, except you. You have to tell it not to. You do that by excluding yourself from being tracked with your own code. Now, your first thought might be to say (inner monologue time), “don’t track anyone who comes from my IP address…” then your second thought might be, “what the hell is an IP address and why do I care?” So in the spirit of true helpfulness I’ll answer both. Tracking via IP addresses is, in my opinion, a messy idea. Your IP address is the number or “address” (hence the name, and allowing me to use the word “hence”) from where your computer is connecting to the internet. Not a bad idea, at least superficially, to think that “I should exclude visits to my website that originate from here”. But then you realize, “wait, I have a laptop, what if I connect to my website at home?” or, “what if my IP address changes for some reason?”.
So the solution, then, is to exclude your visits by using a cookie. This is the way we’re going to do it, and here’s an oversimplification of exactly what we’re going to do:
- We’re going to set a cookie, and set it to some value (entirely up to you!).
- Then, we’re going to tell Google Analytics, “hey, whenever you see this cookie, just don’t count this visit…mmkay?”
This is good for several reasons. First, it allows you to use multiple browsers. Don’t you check your site in Firefox, Internet Explorer, Safari, Chrome, and Opera? Of course you do. This solution means that all the browsers you use can have this cookie set, letting you use multiple browsers without the worry that every time you do, you’re tripping your traffic numbers. Secondly, it doesn’t matter from where you view your site. Look at it on the road, in the airport, on a train, in a box with a fox. As long as you’ve set this cookie, you’re not going to skew your own data. Finally, this allows you to exclude multiple people. Say you’ve got a team of people working on your site, or a business partner, or your significant other, it doesn’t matter, you don’t have to track each of their IP addresses, you just set the same cookie in all their browsers, and be done with it. One nice, clean solution.
Speaking of Solution…
So how do you do this? Well, it couldn’t be easier. You’re going to need to be able to do a couple of easy things. First, you need FTP access to your server, because you’re going to need to send a web page over. Secondly, you need some kind of text editor. I use TextMate on the Mac, you can use Notepad on Windows, or any number of text editors that are out there. And lastly, you’re going to have to know how to copy and paste. I know, I know… nobody said you needed a degree in Rocket Science to be able to do this… but it helps!
NOTE: Just to be clear, this Solution is designed to work with Google’s new Asynchronous Analytics Code. If you don’t know what that means, check this out and get back to us. It’s okay, we’ll wait right here for you.
Okay, sign into your Google Analytics account and grab your analytics code. To ensure that you’re using the right code, make sure the first line reads:
var _gaq = _gaq || ;
If it does, you’re using the right code. Now we’re going to create a very simple HTML page that you can paste this code into. In your text editor, open a new document and paste the following code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title>Exclude My Visits!</title> </head> <!-- STEP TWO: Our One Line Piece of Code Goes In The Body Tag Below --> <body > CONGRATULATIONS! YOU WON'T BE COUNTED BY YOUR OWN GOOGLE ANALYTICS NOW! HOORAY! JUMP FOR JOY! <!-- STEP ONE: Your Google Analytics Code Goes Right Below This Line --> </body> </html>
Save that page as something like, “exclude.html”. Go ahead, be imaginative, now’s your chance! Now, where it says, “STEP ONE”, copy your Google Analytics code and paste it right below that line.
Finished with that? Good, now for step two, and this one’s a doozy. Copy this line of code:
Now, paste it right into that <body> tag RIGHT below “STEP TWO”. If you’ve done this correctly, your code should look like this:
Save your work, and upload that to your server. You’re now done with step one.
The first part of our solution created a cookie in your browser. This page you’ve created does just that. In step two of our solution, we’re going to create a filter in Google Analytics that basically tells Google, “hey, whenever you see this cookie? Yeah, ignore it and don’t count the visit…”
For help on creating a filter, go here. It’s Google’s own Analytics Help that explains exactly how to do that if you’ve never done it before. You’re going to create a filter with the following settings:
Filter Type: Custom filter > Exclude
Filter Field: User Defined
Filter Pattern: test_value
Case Sensitive: No
Notice the “Filter Pattern”? I’ve made it blue to match the code above because that’s the value that the cookie sets. Now, here’s the cool part. You created a page called, “exclude.html” (or whatever your little heart desired) now go there! Once you visit that page, you’ll have the cookie, and when your filter is implemented you’ll be excluding yourself (well, that browser) from registering any visits in your Google Analytics!
Make sure you visit that page anytime you “clear your cookies”! Send the URL to that page to anyone you want to exclude and sleep well at night knowing your numbers are safe.