What Are Good Foundational Google Analytics View Filters?

04/20/2020 Reading Time: 4 Minutes

What Are Good Foundational Google Analytics View Filters?

The enemy of data analysis is dirty data. It is something that businesses deal with every day and while it is manageable in most cases, the unmanageable and most detrimental type of data to your business are those that are unknown/unidentified. This type of data can be present in any database without the experienced eye of a data practitioner and something that is commonly found when dealing with web analytics platforms.

Thankfully there are tactics that you can use to prevent dirty data from being recorded in your web analytics platform and today I am going to be talking about tactics that can be used for Google Analytics. I believe that every view setup should consider adding these view filters to prevent unknown data points from being included in your reports.

Removing your home and office IP Address

Employee interaction with your website is a quick way to dirty your data and impact your engagement metrics. What makes this a tricky variable to remove from your Google Analytics reporting is because IP addresses are not a reportable dimension, which means that even if you were to recognize that traffic from your office was being tracked, you wouldn’t be able to filter this traffic out from already recorded data. Since view filters are the only method to exclude this information, it is important you add filters for office, contractors and home (if possible) IP addresses.

To filter an IP address from your view filter:

  1. Click on the “Admin” button located in the left side bar navigation.
  2. Click on “Filters” located in the “View” section of the “Admin” page.
  3. Click on “+ Add Filter” and use the “Predefined” filter type with “Exclude”, “traffic from the IP Addresses”, “that are equal to” selected
  4. Enter the IP address that you want excluded
google analytics ip address exclusion view filter

Including the correct environment or sub-domain (hostname)

If you are running an online business, then you are likely to have multiple web development environments and sub-domains that store code for new features and typically these environments live on sub-domains like dev.my-domain.com or staging.my-domain.com. To ensure that your view is not registering traffic from subdomains that shouldn’t be tracked, then it is highly suggested that you add an “Include Only” filter to each of your views specifically stating the environment or sub-domain that should register data to this view.

To add a hostname filter:

  1. Click on the “Admin” button located in the left side bar navigation.
  2. Click on “Filters” located in the “View” section of the “Admin” page.
  3. Click on “+ Add Filter” and use the “Predefined” filter type with “Include Only”, “traffic to the hostname”, “that begins with” selected
  4. Enter the hostname including the sub-domain, www or just the hostname if the DNS is configured to use a non-www record.
google analytics hostname view filter

Setting a page path preference

A frustrating scenario that many analysts deal with when analyzing page reports are duplicate URLs due to formatting differences. This scenario typically occurs when a user has the ability to access a web page with or without a trailing forward slash in the URL (e.g. www.my-domain.com/help and www.my-domain.com/help/). Google Analytics recognizes this slight difference as two distinct pages making it difficult to analyze how that page is performing unless data is transformed. Thankfully there are view filter formulas that will allow you to standardize how the URLs should be formatted before being recorded to a view.

To add this filter, first consider if you would or would not like a trailing slash in your Google Analytics data.

To remove any trailing slash:

  1. Click on the “Admin” button located in the left side bar navigation.
  2. Click on “Filters” located in the “View” section of the “Admin” page.
  3. Click on “+ Add Filter” and use the “Custom” filter type with “Advanced” and “Request URI” selected for the “Field A -> Extract A” and “Output To -> Constructor” fields
  4. Enter the following value for “Field A -> Extract A”, ^/(.?)/+$ and $A1/ for “Output B -> Constructor”
google analytics remove trailing url path forward slash

To add a trailing slash if one isn’t present:

  1. Click on the “Admin” button located in the left side bar navigation.
  2. Click on “Filters” located in the “View” section of the “Admin” page.
  3. Click on “+ Add Filter” and use the “Custom” filter type with “Advanced” and “Request URI” selected for the “Field A -> Extract A” and “Output To -> Constructor” fields
  4. Enter the following value for “Field A -> Extract A”, ^(/[a-z0–9/_\-]*[^/])$ and $A1/ for “Output B -> Constructor”
google analytics add trailing url path forward slash

📬 Subscribe to My Newsletter

Get the latest articles and exclusive content straight to your inbox.