Power Feature: Google Analytics Filters
A few weeks ago one of our customers asked for the ability to filter data returned from Google Analytics, they wanted to see pageviews for specific URLs on their Geckoboard status board. Yesterday we quietly rolled out that feature to all customers and I wanted to show you how you can use it to filter both dimensions and metrics from Google Analytics.
You can find lots of in-depth information on how to write Google Analytics filters on Google's documentation page but for now I want to run through a couple of practical examples.
To start, let's create a new Google Analytics widget: New widget >> Web Analytics >> Google Analytics. You'll notice a new (optional) field called "Filters" on the widget configuration screen. Entering filter parameters in here allows you to filter by almost anything including multiple dimension and metric filters together.
Let's start by adding a filter to show only pageviews by Firefox users from the United States. Use the following settings in the widget configuration
- Metric Category: Visitors
- Metric: Pageviews
- Filters: ga:country==United States;ga:browser==Firefox
Breaking that down, we're using ga:country to restrict pageviews that came from the country "United States". We used the operator == here which ensures it's an exact match, but there are other operators we can use including =~ which matches based on a regular expression. An example of this might be to add a filter to restrict pageview numbers where the URL matched a regular expression.
If you want to restrict the pageview metric to only URL matching ^foo (i.e. your URL starts with foo), add the following filter
ga:pagePath=~^foo
To match ^foo OR bar$ (url starts with foo OR ends with bar) you need to use a comma to separate terms:
ga:pagePath=~^foo,ga:pagePath=~bar$
To match ^foo AND bar$ (url starts with foo AND ends with bar) you use a semicolon to separate terms:
ga:pagePath=~^foo;ga:pagePath=~bar$
This doesn't scratch the surface of what's possible with Google Analytics filters but a look at the documentation and some experimentation should get open up a ton of possibilities.
Don’t forget, use our RSS feed or our Twitter or Facebook profiles to keep up-to-date with news and future updates.
