How to Filter Admin Traffic in Google Analytics

How to Filter Admin Traffic in Google Analytics

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].

New Filter in Google Analytics

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. 24.115.139.53).

Add IP Filter in Google Analytics

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.

Cookie Page

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.

<!-- Google Analytics Code -->
<script type="text/javascript">// <![CDATA[
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-12345678-9']);
  _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>
<!-- Google Analytics Code -->

The above part contains the Google Analytics code, but make sure that you replace that account number with your own one.

</head>
<body onLoad="javascript:pageTracker._setVar('filter_traffic');">
<h1>Excluding traffic by Cookie Content</h1>
<p>This page will set a cookie in your browser that will help Google Analytics filter the traffic that comes from your computer when using this browser.</p>
<p>Once you have this setup, don't forget to set a filter in Google Analytics.</p>
<p>You will need to visit this page only once.</p>
<p>However, if you clear your browser cookies, reinstall the broser or operating system, make sure that you revisit this page, so the cookie will be set again.</p>
</body>
</html>

Finally, add the rest of the code along with some instructions for your colleagues/employees.

As you can see the body tag contains a JavaScript that will set a custom variable which will be later filtered in Google Analytics.

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.

Add Custom Filter in Google Analytics

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.

Enjoyed this article? Get Updates! It's free!

Learn more about increasing email subscribers and converting more traffic into loyal customers. Join and you will get:

  • 7 biggest conversion mistakes and how to fix them
  • Google Analytics course
  • Fresh content to help you build a profitable business

Powered by Elevatr

1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 5.00 out of 5)
Loading...Loading...
About Eugen Oprea

I am passionate about technology and I love to help people confused by technology build a remarkable presence online. To find out more about me check my profiles on Twitter, Facebook, or LinkedIn.

Comments

  1. Adrian Markwell says:

    In your ‘Cookie’ code snippet you appear to use the wrong quote marks.

    Should it not be…
    meta name=”robots” content=”noindex”
    instead of
    meta name=”robots” content=”noindex”

    • Adrian Markwell says:

      …hmmm… now that’s strange…
      In my comment above it shows them as the same…but theye are different when they were in this editing box (and when I copied and pasted the code from the archive file supplied)

  2. Hi Eugene,

    I am not able to see ‘In-Page Analytics’ data for .swf Banners, Outbound links, GIF links….what may be the reason?…I use a content management system and all settings are enabled to track these….

    A

    • Adarsh, I suspect that Analytics might not track .swf banners, but you should see In-Page Analytics data for outbound links, if it is.

      If people click links on your site, you should see that in the report.

      Eugen

  3. Hello,

    You could use a google chrome extention:
    Google Analytics Opt-out Add-on
    https://chrome.google.com/webstore/detail/fllaojicojecljbmefodhfapmkghcbnh

    I leave it running all the time ;-)

    Peter

    • Hey Peter, thanks for the suggestion!

      I agree that you can also use that extension, but that will block Google Analytic on all sites.

      Personally, I think that as long as I want to see data about my visitors, I should also let others see data about my activity on their site.

      Let’s say that I see this as a win-win situation for everyone.

  4. I add filters to the profile to filter out all pageviews where the hostname matches the dev site address.

    Exclude:
    Filter Field: Hostname
    Filter Pattern: dev\.example\.com

  5. Thanks for the clear instructions — really easy to follow. You learn something new everyday! Cheers Eugen

  6. Thanks for this post, I found it while trying to set up a clients page, I always forget how to do this in between site set ups, must get in the habbit of removing my data before working on the site :)

  7. First, THANK YOU so much for writing this post. However, I don’t know when this article was written because under Google Analytic account, I can’t add a filter based on IP address for some reason. May be Google have removed it. If you know where can I find it, please, let me know.

    Thank you.

  8. Thank you for explaining things so clearly (why can’t Google with its billions of turnover explain things as well? they should obviously hire you…)

    Regarding the quote marks around “robots” and “noindex” – in the file I downloaded there were no quote marks, double or single, around these words – so I added them (hope I did the right thing).

    Anyway thanks again Eugen and if you ever need business planning software get in touch and I’ll give you a big discount!

  9. Eugen:

    Do you know if there is a time laps of filters becoming active after you add them to GA?

    Great article! thanks.

    -T

    • Thomas, it will filter the traffic from the time you apply it.

      But you can create a custom segment to filter out your own traffic from previous dates.

  10. Daniel Sandberg says:

    Hi Eugen,

    I’m not getting this to work. I’ve created the Html document, changed the account to my own.
    I’ve set up the filter in GA as described.

    After that set up I put the the file on my server and pay it a visit from a browser on my local computer. Still I can see that my visit reflects the real-time data on GA. What do you reckon I’ve missed?

    Thanks in advance =).

    /Daniel

  11. Hi @Eugen,
    I followed all details, but when I go to google analytics real time I’m continuing to see myself connect to the page! How can I do it?

    Thanks

Trackbacks

  1. […] How to Filter Admin Traffic in Google Analytics: Super useful step-by-step instructions on how to make sure you are not included in site visit counts! […]

Are You Making These 7 Conversion Mistakes?

Conversion Mistakes

Discover the 7 biggest conversion mistakes that people make (and how to avoid them, so you can get more subscribers and sales).

Join my private newsletter and get the course that will show you:

  • A sneaky way to figure out exactly what your audience wants
  • The easiest way to see where your visitors lose interest and click away
  • How to convert more visitors to email subscribers, and build a list that converts

Powered by Elevatr