You probably know it too well, right after you work on your site you access Google Analytics and see an increase in traffic.
But the question is: How do I exclude my own traffic?
It’s obvious that you need to filter out all admin traffic from Google Analytics, and you can do that straight from Google Analytics.
There are two methods to filter traffic:
- Excluding your IP address
- Excluding traffic by Cookie
If you have a static IP the first option will be best, but only if you access the site from your home/office. If you find yourself accessing it on the go you will have to use the second method instead.
If your IP address is dynamic or if you often leave your home/office desk this method will suit your needs better.
As you can see, every method has its advantages and disadvantages, but before we start I recommend you to create a new profile inside Google Analytics by going to Admin → Profiles → New Profile and name it something like “Excluded Traffic”.
Side Note: I for example have one profile blgg which excludes my traffic and another one blgg (All Traffic) which includes my traffic.
Method 1: Exclude your IP address
This is by far the simplest method, but keep in mind that this only works if you have a static IP address. If you have a dynamic IP you can skip to Method 2.
To exclude traffic by IP you need to create a custom filter in Google Analytics.
To do this select the filter profile you created earlier, select the Filters tab and click on New Filter.
- Filter Name – add a name for your filter
- Filter Type – select
Predefined filter - Then, select
Exclude,traffic from IP addresses,that are equal to - IP address – type in your IP address
If you have a range of IP addresses you want to exclude, take a look at the Analytics Help Page for creating regular expressions.
Eventually click Save to add the filter.
Method 2: Exclude traffic by Cookie
By excluding traffic using the cookie method the filter is not locked to a single IP address, however, whenever you change your browser, clear your cookies or switch to another computer you have to visit the page we are going to make again.
But now let’s see how to set this up.
Cookie Exclude Page
You need to create a HTML file containing the following code, name it something like ga-filter.html.
<!DOCTYPE html >
<html>
<head>
<meta name="robots" content="noindex" />
<title>Filter Admin Traffic</title>
This part adds a nofollow meta tag so that this page doesn’t get indexed by search engines.
<!-- Analytics -->
<script type="text/javascript">;// <![CDATA[
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXXX-X']);
_gaq.push(['_trackPageview']);
_gaq.push(['_trackPageLoadTime']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
// ]]></script>
</head>
<body onLoad="javascript:pageTracker._setVar('exclude_traffic');">
Please make sure you replace the Tracking Code UA-XXXXXXXX-X in the Google Analytics code above with your own. You can also change exclude_traffic to something else.
<h1>Excluding traffic by Cookie</h1>
<p>This page will set a cookie to help exclude your traffic from Google Analytics.</p>
<p style="color:red">Don't forget to visit this site again if you switch your browser or computer or clear your cookies.</p>
</body>
</html>
Optionally you can add some instructions and finally.
Save this as a HTML document and upload it somewhere onto your server.
Next, visit the page with your browser and you are all set for the final step.
Add a filter to Google Analytics
Now you have set the cookie, but the filter is not set up yet.
In Google Analytics go to Filters, select Custom filter.
Select Exclude to exclude traffic, User Defined as Filter Field and add exclude_traffic to Filter Pattern.
Finally click the Save button to add your filter.
If you have any questions feel free to leave a comment.
