A Google Analytics (GA) Property can be split into multiple Views, to simplify your analysis and limit the data visible to different stakeholders in the organization.
Using filters, the GA account admin can limit each View to a specific subset of data collected by the Property.
In this post I will explain how to create filters with examples of common filters I use.
Important notes on filter
- Filters can only be created by users with Edit permissions to the Google Analytics account. Other users can only add or remove an existing filter to a View.
- Filters are managed on the Account level and can be shared across Properties and Views.
- Filters do not apply retroactively so that they will only effect data from the point they were set and onwards. If you have damaged data in your View, it will not fix that (you can probably use a Segment to fix most of it).
- Multiple filters can be applied to a single view, but they will act in the order in which they are set.
- A good example is filtering out internal traffic and then only traffic to the blog, which will return a “clean” view of non-employee blog traffic.
- A bad example is filtering in only traffic from the UK and then only traffic from Argentina. This will result in no data, as no user can answer both criteria simultaneously.
Creating a Filter
- To create a filter, navigate to your account’s Admin page.
- Select the relevant Account, Property and View
- Under the View column, click on “Filters”
- You will see a list of the existing set for this View and their order
(you can set the filter’s order by clicking “Assign Filter Order”)
- Click “+Add Filter”
- You can then choose to create a new filter or apply an existing one from your account
- When creating a new filter you also need to set its name. I recommend using descriptive names, e.g. “Exclude internal traffic” or “Include only blog traffic”
Creating a Predefined Filter
Google Analytics offers four standard filters as predefined, making them simple to create.
- Select the Filter Type “Predefined”
- Select the filter type, Exclude or Include.
- Exclude will filter OUT sessions that match the criteria
- Include will filter IN only sessions that match the criteria
- Select the filter criteria – What do you want to filter by?
- ISP Domain – This filter is obsolete as this data point has been depracated in 2020
- IP Addresses – This filter can be applied to filter out internal traffic (or filter in only Dev traffic)
Your IP address can be easily found by Googling “What is my IP address”. This filter can also be applied to an IP C-Class to exclude multiple IPs.
- Subdirectories – This filter can be applied to include only traffic to a specific subfolder on you site, e.g. a blog that sits under /blog
- Hostname – This filter can be applied to include/exclude only traffic to a specific domain or subdomain, e.g. a blog that sits on blog.example.com
- Select the criteria expression – How do you want to match the criteria?
- That are equal to
- That begin with
- That end with
- That contain
- You can then add the criteria to match in the field shown
After the filter is set up, you can test the filter before saving by clicking “Verify this filter”. This will test the filter against traffic from the past 7 days to see how the data would have been impacted. If this is a new account without previous data, this test is irrelevant.
In the case of IP related filters, this test isn’t supported as Google Analytics doesn’t store IP data for future reporting (it is only used in the initial data processing of a session).
Creating a Custom Filter
For more complex uses, Google Analytics offers the option for Custom Filter. Aside from include/exclude filters, these filters can also be used to manipulate the data collected by GA.
Exclude and Include
Similarly to the Predefined filter, you can Include/Exclude sessions based on almost any data point available in GA. Unlike the Predefined filters, these use Regex (Regular expressions) for matching the string. If you’re only using numbers and characters, in most cases this won’t make any difference.
You can “dry run” these filter in advance in almost any report by creating an advanced filter with Regex matching
For example, campaign data in GA is case sensitive, so the reporting for Summer-Love-2020 and summer-love-2020 will be split into two separate campaigns. With the Lowercase/Uppercase filter, you can enforce a unified naming convention.
I personally always default to lowercase.
Search and Replace
This filter is useful for fixing errors that are out of our control or removing sensitive data from GA.
For example, if a partner of yours is linking to your website with the wrong UTM parameters, you can easily capture these and update to the right ones.
This filter can be used to remove sensitive data, such as personally identifiable information (PII) from the URL.
Filters I use
Exclude internal traffic
Useful for maintaining your GA data clean from employee traffic.
Your IP address can be found by Googling “what is my IP address”. In an office setting, I recommend asking your IT team.
Include traffic to my domain
This filter is useful for blocking spam traffic on your GA account (it’s a thing, really). It will only include sessions that have landed on your domain.
Include traffic to a subdomain
This filter will include only traffic to a certain subdomain, e.g. blog.trackingchef.com
Include traffic to a subfolder
This filter will include only traffic to a certain folder, e.g. trackingchef.com/blog
If this is the top most folder, I recommend using the expression “that begin with”.
Include traffic from a specific country
This filter is a Custom one.
You can concatenate several countries in a single filter with a | (pipeline) between them, e.g. United Kingdom|Argentina|Pakistan
Include traffic from a specific source
This filter is useful when I want to analyze only a specific traffic source or when working with a vendor in charge of a specific source, e.g. your SEO agency. This example will filter in only traffic from Organic channels (Search Engines).
Add hostname to path
When working with multiple domains or subdomains under a single Property, the View level reporting will not show the hostname by default, causing much confusion in analysis. To resolve this, you can add the Advanced filter to prepend the hostname to the URL.
Advanced Field A -> Extract A:
- Select field: Hostname
- Paste (.*)
Field B -> Extract B:
- Select field: Request URI
- Paste (.*)
Output To -> Constructor:
- Select field: Request URI
- Paste $A1$B1
Keep “Field A Required” and “Override Output Field” selected
Leave a Reply