Google Analytics Filters: Tricks for Cleaning Data

Google Analytics Filters: Tricks for Cleaning Data

The first time you start seeing data flowing in from your tracking software, it is really exciting. After all, these are real people that are interested in visiting your website. Depending on your purposes for tracking visitor activities, you may need to filter your data to get a clearer picture of what is happening. Things like internal traffic from an organization, web development activities or just data that you don’t need to see can clutter up your reports and give you an inaccurate or hard-to-sift through pile of numbers. Read on for some best practices on using Google Analytics filters to make customized reports.

STOP! Don’t Apply an Analytics Filter Yet!

Before you do anything, you need to make a duplicate of your profile in your account. This is a copy of the default profile in your account. At the time of this writing, you can make up to 50 duplicate profiles in one Analytics account for one property. The reason you need to make a duplicate is that you should always maintain an unfiltered profile with all of your data in it. Any analytics filter you apply to a profile throws data away. This data cannot be retrieved, and should you make a mistake or decide that you want the data later, it’s gone for good. By making a duplicate profile, you will always have at least one that has not been touched. If you already have a duplicate profile, skip to the next section. If you have never done this, follow the steps below:

  1. Log into your Analytics account
  2. Click the “Admin” link in the top right-hand corner of the accountGoogle Analytics Filter Screen Shot
  3. Select the profile that you would like to duplicate
  4. Click on the “Profile Settings” tab Google Analytics Filter Screen Shot
  5. Click the “Copy this profile” link in the bottom right corner of the screen Analytics Filter Screen Shot
  6. Confirm the copy

Now that you have a duplicate, you can do whatever you want to the copy of your original knowing that you still have the first profile should you screw things up.

Excluding Traffic Using Filters in Google Analytics

A popular filter to apply to a property is to exclude traffic. If you are running a company, you may want to exclude employee traffic from the website. If you are doing some web development activities or someone you have hired is about to, you may want to exclude them from data so that it isn’t skewed. Another reason you might exclude data is to only look at a certain subset of users. Whatever they case, there are a variety of ways to accomplish this.

Exclude Traffic by IP Address

You can exclude traffic from a site based on the visitor’s IP address or a range of IP addresses. To do this, log into your Analytics account and select your duplicate profile.

  1. Click on the “Admin” link at the top of the screen
  2. Click on the “Filters” tab
  3. Click “New Filter” Filters in Google Analytics Screen Shot
  4. Select the “Create new Filter” radio button Filters Google Analytics Screen Shot
  5. Give your filter a name (this can be anything)
  6. If you are only excluding one IP address, you can select the “Predefined filter” option, then “Exclude,” then “Traffic from the IP addresses” and “That are equal to”
  7. Next, enter the IP address

If you are excluding traffic from multiple or a range of IP addresses:

  1.  Follow steps 1-3 above
  2. This time select the “Custom Filter” option
  3. Select the “exclude” radio button
  4. For the filter field, select “IP address”
  5. For the filter pattern, you will have to enter a regular expression for the range of IP addresses you want to exclude. Regular expressions are very difficult to write correctly; however, Google offers an IP address range tool that allows you to do this easily. Use the tool, then just copy and paste your regular expression into the filter pattern field
  6. Make sure “Case Sensitive” is set to “No”

Excluding Visitors by Setting a Cookie

Sometime excluding traffic based on IP address is not practical because computer networks may be utilizing dynamic IP addresses for security. In these cases, you can set a user cookie on the browser to exclude traffic. Note that this method is not ideal because it requires actual people to visit a web page to set the cookie, and the cookie expires or can be erased when someone clears his or her browser cache. It also requires some programming knowledge. Use of this filtering method works best when there are small groups of users that need to be excluded.


The web page where the cookie will be set:

  1.  Create a new html page (there does not have to be content, but you can add some if you like)
  2. Add this snippet of Javascript code into the head section of your new page: <body onLoad=”javascript:pageTracker._setVar(‘exclude_visitor’);”>
  3. Also insert your Google Analytics Tracking script into the head of your page (this can be obtained from your GA account) *Note: this must go after the first snippet above or else GA will record a visit
  4. Save the page to your server (IMPORTANT: you should also exclude this page from search engines via robots.txt! Otherwise, regular visitors whom you do not intend to exclude could also visit the page)

Setting up the filter to exclude traffic:

  1.  Log into your Analytics account
  2. Click on the “Admin” button
  3. Click the “Filters” tab
  4. Create a new filter
  5. Click the “Custom Filter” radio button
  6. Select “Exclude”
  7. For the filter pattern select User Defined”
  8. For the filter pattern use “Exclude_Visitor”

After you have set up the filter and you are sure it is working, go ahead and let the user group that you want excluded visit the page on all the browsers that they commonly use. This will effectively exclude them from reports.

Separating Domains Using Google Analytics Filters

When you have a blog, a web store or some other web property that has a different purpose than your main website, it is best for SEO to keep them all on the same or a sub domain. When looking at this data in reports, however, it can be an arduous process to sort through everything to evaluate activity. For instance, you may want to track activity on your blog separately from that of your main website. Using filters, you can separate these.

Including Traffic to a Sub Directory:

  1.  Log into your Analytics account
  2. Click the “Admin” link in the top right corner of the screen
  3. Select the profile you want to apply the filter to
  4. Click the “Filters” tab
  5.  Select “Create new Filter”
  6. Name your filter
  7. Select “Predefined Filter”
  8. Select “Include only,”  “traffic from the subdirectories” and “that begin with.” Note: if you were to select “that are equal to,” any sub directory past the first would also be excluded.
  9. Enter your subdirectory (i.e. /blog)

There are over 50 different options for your  filter field, and out of those there are almost limitless combinations of how you can exclude or include data. The main purpose of filters is to only keep the data that you want in order to make your reports easier to decipher. Remember that you can create up to 50 different profiles and apply all sorts of filters to your data. Some of the most common are to exclude internal traffic or to separate properties, but you can also create filters based on user location, ISP, browser, campaign, page title and lots of e-commerce related characteristics.


What filters are you using on your data? How do they help you get a clearer picture of your data?

Shawn Manaher

Shawn Manaher is the founder and CEO of The Content Authority. He's one part content manager, one part writing ninja organizer, and two parts leader of top content creators. You don't even want to know what he calls pancakes.

Recent Posts