Have you ever checked your Google Analytics traffic and noticed a high bump? But, was that bump visible right when you did some work on your site?
I know, it happens to all of us. There are periods when we setup something new on the site, work on design or spend a lot of time checking the articles we write. All these count as visits, time is recorded and you end up with inaccurate stats for your website.
So, you need to filter out all the admin traffic from Google Analytics. You can do this with different WordPress plugins, but what if you don’t use WordPress or just don’t want to clutter your site with plugins?
In this case you can do it straight from Google Analytics and here’s how:
Google Analytics allows you to filter traffic using 2 methods:
- By excluding your IP address.
- By excluding traffic by Cookie Content.
The first method is very effective when you have a static IP address and a desktop computer that doesn’t move to a different IP address.
In case you have an IP address that is dynamically generated or if you work from a laptop and spend a lot of time in coffee shops, on client sites or when vising friends, then the second method is way more effective. You wouldn’t want to start hunting IP addresses from everywhere, don’t you?
Each method has it’s advantages and disadvantages, so let’s see which one suits you needs and how to set it up.
1. Exclude your IP address
This method allows you to set it and forget it. All the traffic from a specific IP address or an IP range will be excluded starting with the time you set this up.
However, if you use a laptop and leave your office/home often, this is not effective anymore, so you might want to use the second method.
To exclude traffic by IP address you will need to create a custom filter in Google Analytics that will instruct the Google Analytics application to not take into consideration the traffic that is made from a specific IP address or a range of IP addresses.
So log into your Google Analytics account, click the settings section from the top right section and select [Filters].
Now press the [New Filter] button and start to add information about your new filter:
- Filter Name – add a name for your filter
- Filter Type – select [Predefined filter]
- Next, select [Exclude], [traffic from IP addresses], [that are equal to]
- IP address – add you IP address in those fields (e.g. 18.104.22.168).
In case you have a range of IP addresses that you are looking to filter, then you can use this tool to generate a regular expression.
Finally, press the [Save] button to add the new filter to your Google Analytics profile.
2. Exclude traffic by Cookie Content
By excluding traffic using the cookie content method, the filter is not locked to a single IP address or a range of IP addresses.
However, the downside is that if you change your browser, reinstall your operating system or clear your cookies, your traffic will be tracked again.
But let’s see how you can setup this method and what you need to do to make sure that your traffic is still excluded.
First you need to create a file that will add the cookie to your browser. To do that, just create an HTML file called [filter-traffic.html] and add the following content to it:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Excluding traffic by Cookie Content</title> <meta name=”robots” content=”noindex” />
This part starts the HTML document and instruct the search engines robots/spiders to not index this content. This is important because you will not want visitors to come to this page, as they will be excluded from your statistics.
The above part contains the Google Analytics code, but make sure that you replace that account number with your own one.
Finally, add the rest of the code along with some instructions for your colleagues/employees.
Save this as a basic HTML document and add it somewhere on your server through FTP in a location that can be accessed easier from your browser. You can add it to your root folder.
To make it easier for you, I added the page in an archive for you to download. Just click here to download the archive.
Next, extract the [filter-traffic.html] page from the archive, add your Google Analytics account number and copy it to your server. I didn’t linked directly to the page, because I don’t want the cookie to get on your browser.
Before going to the next step, visit the page you just added on your server from all the browsers that you are using and all your computers.
Please note, that if you clear your cookies, reinstall your browser or Operating System, you will need to access that HTML page again.
Add a filter to your Google Analytics account
Now that you have the cookie in your browser, you need to setup a filter that will exclude the traffic coming from your computer.
Go again to [Filters] in your Google Analytics account and this time, select a [Custom filter].
Select [Exclude] to exclude traffic, [User Defined] as [Filter Field] because the you are setting the custom variable and add [filter_traffic] to [Filter Pattern].
[filter_traffic] is what we have used as a custom variable in the body tag of the HTML document.
Finally, click the [Save] button to save your filter.
Very important it’s the fact that this method actually excludes the data from your Google Analytics account. If you think that at a moment in time you will want to analyze internal traffic, then use the Cookie Page option, but DO NOT apply a filter. Instead, use custom segments to do it. You can learn about custom segments in my Google Analytics course.
Now, you should be all setup with a filter to exclude the traffic from your computer while editing the site, working on the design or checking your own articles. Even if I hope that the process will run smoothly, do let me know in the comments section below if you have any questions.
So, let me know how the process went and if you have any questions. Use the comment section below to do it.