Google Analytics provides a lot of data. While having an overall portrait is necessary, sometimes, you might want to look at more specific pieces of information. This is when filters come in handy.
Filters allow you to refine the data shown in your widgets according to your needs. For example, you can filter your page impressions according to the country in which they occurred or device on which they occurred. You can use filters on both metrics and dimensions.
- 1 – Syntax
- 2 – Filters for dimensions
- 3 – Filters for metrics
- 4 – Combination
- 5 – Multi-channel funnels
- 6 – In DashThis
1 – Syntax
First, you need to know how to write a filter. Filters in Google Analytics require a specific syntax, which looks likes this:
If we replace each of the variables with their official terms, it looks like this:
Name: This is the name of the dimension or metric you want to apply a filter to. For example, ga:pageviews will apply to the metric called “pageviews”. To know the exact name you need to write, please refer to the Google Analytics documentation. Filters are case-sensitive, so be sure that your capital letters are in the right place!
Operator: This is the formula that will be applied, such as equal to, greater than, less than, etc.
Expression: This is the value to which the operator applies in order to either include or exclude data.
In our previous example ga:country==Canada
2 – Filters for dimensions
There are six operators you can use in order to filter dimensions.
2.1 – Substring and regular expression
Substring? Regular expression? If you’re not familiar with coding and computer science, these terms might not mean much to you.
A substring is a sequence of characters contained in a longer sequence of characters; “Dash” is a substring of “DashThis” for example.
A regular expression (called RegEx) is a formula that defines a pattern. It’s more flexible and can offer many possibilities.
Regular expressions have multiple functions and can easily become complex. In the context of writing a Google Analytics filter, you probably won’t need to dive too deeply into formulas and endless options.
However, if you want to learn more on regular expressions and unleash their power, we suggest you explore the guide to regular expressions in Google Analytics. You will find an overview of the different symbols you can use and their functions, as well as other tips and tricks.
3 – Filters for metrics
There are six operators you can use in order to filter metrics.
|==||Equal to||Returns data that is equal to the expression.
Ex: ga:uniquePageviews==5 will only show results where the number of pages viewed is equal to 5.
|!=||Does not equal||Returns data that is different from the expression.
Ex: ga:pageviewsPerSession!=1 will only show results where the number of pageviews per session is not equal to 1.
|>||Greater than||Returns data that is greater than the expression.
Ex: ga:timeOnPage>60 will only show results where the user spent more than 60 seconds on a page.
|<||Less than||Returns data that is less than the expression.
Ex: ga:sessionDuration<30 will only show results where the sessions lasted less than 30 seconds.
|>=||Greater than or equal to||Returns data that is greater than or equal to the expression.
Ex: ga:impressions>=100 will only show results where the impressions are greater than or equal to 100.
|<=||Less than or equal to||Returns data that is less than or equal to the expression.|
4 – Combination
It’s possible to combine filters to personalize the query even more. You can combine them either with an AND or an OR.
The OR operator is the comma ( , ) : ga:country==canada,ga:country==australia means the query will return results that are either Canada OR Australia.
5 – Multi-channel funnels
If you want to apply a filter on multi-channel funnel metrics, the filter syntax is going to change a little bit. Instead of beginning with ga, the filter has to start with mcf. The result would look like this: mcf:source==facebook. Please refer to Google Analytics documentation on multi-channel funnels to know how to write the name in your filter.
How do you know if the metric you want to choose is a multi-channel funnel metric? Easy!
When you create a widget in your dashboard, choose the option Custom widgets, located on the top-left side of the screen. Choose the type of widget you want and Google Analytics as your data source. A drop-down menu called Metric is there, at the very top of the panel. The metrics are categorized under different sections, and one of them is called Multi-channel funnels. They’re all there!
6 – In DashThis
It’s time to apply them to your DashThis widgets and get the information that specifically matters to you.
6.1 – New widgets
In the Editor mode, click on the Custom widgets option. Choose the type of widget you want to create as well as the metric and the dimension, if applicable. There is a field called Filter, which is where you’ll write your filter!
6.2 – Existing widgets
You can also apply filters to already existing widgets.
Hover over the widget, and click on Edit widget, located on the right side of the widget. The panel Edit widget appears. Under the section Basics, there is a field called Filter. Make the magic happen, and then click Save.
You now have the info you need in your widget!