Introduction

Filters are a great tool. Really. Using Google Analytics filters allows you to quickly manipulate and play around with your data, remove information you’d like to exclude, and create beautiful view modes for various occasions. 

But with every great tool comes a long list of instructions on how to properly install it. 

Google Analytics filtering is one of the trickiest functionalities when it comes to Google Analytics setup. To quickly figure out how Google Analytics filters work, read this article and follow each of the steps that will guide you towards successful Google Analytics filters setup. 

Recommended Views

First things first – filters cannot be used to parce the data from the previous periods, only the data coming in after you set filters up. Filters are processed in order, so make sure you organize your filters in the proper sequence.

Google Analytics Views allow creating certain prisms, or glasses if you wish, through which you can view your data according to your needs. You’ll need at least 3 different view setups corresponding to various analytics functions which we are about to review right below. 

Raw data view

Your ‘unfiltered’, or raw data view is exactly what it sounds. Raw data view reflects all of the data tracked and collected by Google Analytics, showcasing the total stats and traffic on your website. It includes every little digit and every large total. Creating a raw data view is crucial, for it serves as a backup for all of your data, and ensures that you have a safe place to store all of the important info. 

Test view

Google Analytics custom filtering is tricky, this is why our next big tip on how Google Analytics filters work is to use “Test View” first. Why? Well, the setting you chose for a Google Analytics filter and therefore its outcomes cannot be undone, which means it’s a good, safe practice to apply your freshly-created filters to a Test View, and only then use it as a Main View filter. These extra couples of days in the Test view will allow you to confirm the rightfulness of the findings. 

To simplify, the Test View can utilize the same settings as your “Main View” used for typical tracking and reporting means. Once you’re happy with the results of the given Test filter, you can make it your Main view.

Main view

Main view, or Master view, is the Google Analytics filter made for your every day reporting. Regardless of the name you give it, be clear with your team members that this is the main, dominant, the King filter used for reporting. 

How to create a Google Analytics filter?

Now that we quickly established how Google Analytics filters work, let’s move on to actually creating our custom filtering. Follow this step-by-step Google Analytics filters tutorial and you’ll end up with a new, shiny filter ready to go!

Let’s begin!

Step 1.

Check the left bar dedicated to the settings and click on “Admin”:

Step 2.

In the admin panel you will see two ways to create a filter:

  1. Filters on “Account” level
  2. Filters on “View” level

When you go either “All Filters” or “Filters”, you will see the list of your existing filters. 

Step 3.

To create a new one, click “Add Filter”:

Step 4.

Through the Admin panel you are able to apply one filter to multiple views. 

Fill in the required fields and add filer to a needed view:

Step 5.

On the View level, you can verify your new Google Analytics filter and monitor how the changes will reflect on the existing data in the view.

Step 6.

After you create a filter within the View level, you will also see this freshly-created filter on the Admin level and will be able to apply it to any additional view setting.

Data Collection Filters

Consistency is key when it comes to gaining accurate data. Make your data more precise and consistent by using the filters described below.

Exclude Internal Traffic

Define your View settings to only include external traffic and therefore exclude internal traffic. Sounds tricky, right? It’s not really, having this view in place is a great way to register when and how people access your website without your internal team’s actions interfering with the stats.

  • Filter Type: Custom → Exclude
  • Filter Field: IP Address
  • Filter Pattern: IP address to exclude

Include Specific Hostname

Include a Specific Hostname filter is one of the most useful filters you can create. The hostname is “the domain of the page a visitor is on when they send a hit to Google Analytics”. Important notice – only include traffic from people visiting your website. This technique will allow you to get rid of a whole bunch of weird referral spam and traffic that never really reaches your website through the measurement protocol.

  • Filter Type: Custom → Include
  • Filter Field: Hostname

Filter pattern:

^(www\\.)?insightwhale\\.com$

Exclude Dev Site Traffic

Exclude development & staging traffic data from your website’s production view, use the setting below:

Data Consistency Filters

Prepend Hostname to Request URI

Using this filter is crucial when it comes to installing a cross-domain tracking system. What it does is it adds the hostname at the front of the Request URI for every pageview hit that occurs, and then overwrites the Request URI with this new, updated format. After applying this magic Google Analytics filter, you will have all of the pages with their new corresponding hostnames.

Example: Say you are monitoring two domains – exampleEurope.com and exampleUSA.com. Assume that the Request URI to the homepages of both sites is index.html. After applying this Prepend Hostname to Request URI filter in your Cross-Domain View, in your All Pages report section you will see the following Pages:

  • Filter Type: Custom > Advanced
  • Field A -> Extract A:
    • Select Hostname
    • Enter (.*)
  • Field B -> Extract B:
    • Select Request URI
    • Enter (.*)
  • Output To -> Constructor:
    • Select Request URI
    • Enter $A1$B1
    • Select Field A Required
    • Select Override Output Field

Now you can apply this GA filter to the Cross-Domain View.

Remove Query String

In some cases, you may need a clean view that eliminates all query strings from your page URLs. You can achieve this with an advanced Remove Query String filter,

Tutorial to which is described below:

  • Filter Type: Custom > Advanced
  • Field A -> Extract A:
    • Select Request URI
    • Enter
      ^([^?]+)
  • Output To -> Constructor:
    • Select Request URI
    • Enter $A1
  • Select Field A Required
  • Select Override Output Field

Append Slash to Request URI

So this is the deal – when your website visitors are able to access a webpage with and also without using a trailing slash, Google Analytics would track and mark a separate pageview for each visitors case.

If there are separate rows for the exact same page paths in your All Pages report with and without the trailing slash, we advise you to keep reading and create this filter.

Important note – make sure this is the last filter in the view, so it doesn’t mess up any prior configurations.

  • Filter Name: Append Slash to Request URI
  • Filter Type: Custom > Advanced
  • Field A -> Extract A:
    • Select Request URI
    • Enter
      ^(/[a-zA-Z0-9/_\-]*[^/])$
  • Output To -> Constructor:
    • Select Request URI
    • Enter $A1/
    • Select Field A Required
    • Select Override Output Field

Search and Replace Filter

Search and replace the filter is just like our favourite tool within Google Docs functions. Create this awesome custom filter to search for a certain bit of information and adjust it prior to it getting recorded once and for all in the aggregated tables.

Example: Imagine the site pages are allowed to be accessed with and without the famous www. As a consequence, Google Analytics would create two rows which include both cases for each page, which is too many rows, right? So to eliminate this little glitch and unify your pageviews, create this amazing Search and Replace filter.

  • Filter Name: Search and Replace www Filter
  • Filter Type: Custom > Search and Replace
  • Filter Field: Hostname
  • Search String: ^example\.com$
  • Replace String: www.example.com

Lowercase page URLs

Okay, so we all know how Google Analytics is sensitive. Well, not personality-wise, although it might be, more like case sensitive, which means the way people type in page names makes a difference. 

For example, the act of going to the homepage can display the page as /default.aspx or  /Default.aspx, which means your Google Analytics will create two separate rows in the ‘All Pages’ report, although really its the same page all along.

You can use this exact same technique to lowercase your search terms, hostnames or any other Google Analytics field.

Data Source Filters

Include a Country

Sometimes we want a filter made exactly to our specific needs, including filtering a particular country, region etc, in which case follow this sequence:

  • Filter Name: Include US Traffic Only
  • Filter Type: Custom > Include
  • Filter Field: Country
  • Filter Pattern: United States
  • Apply the filter to the US Traffic Only View

If there are multiple countries you’d like to include in a viewing, enter a “|” separating sign between them, which will look something like this – India|Guatemala|Australia.

You can create similar filtering for any other fields like Source, Device, Medium, City, etc.

To improve the quality of your data even more, exclude payment gateways for your ecommerce website using exclusion lists, described in our article here.

Conclusion

Now that you got to the end, you have a list of filters which are recommended for your Google Analytics set up. You can choose to use some of them or all of the filters described above. In any case, to make sure that you are getting accurate data constantly and can analyze your business with pixel-perfect precision, create, add and utilize your filters 🙂