Colin White

6 Best Practice Filters for Google Analytics

Get clean, easy to use Google Analytics data

Keeping your data clean is a HUGE task, and a painful one. Unfortunately one of the worst thing when trying to do analysis is dirty data. Sifting through the numbers and not knowing if the conversions you got are from you testing or some real person who hit your site. It’s the worst.

Fortunately in Google Analytics there are some easy ways for you to quickly clean up your data to keep it easy to use.

I’m going to run through some of my best practice Google Analytics Filters so you can easily run the analysis you need on clean, healthy data.

Google Analytics Filters

For people who don’t know what Google Analytics Filters are, I’ll break em down for you.

Google Analytics Filters allow you to include/exclude or modify almost any dimension in Google Analytics (things like source/medium are dimensions). This includes IP Addresses, Hostname/URI etc.

You access your Google Analytics Filters through the Admin panel. On the bottom left of the page, hit Admin and you’ll find the Filters view on the right hand column.

Filters are per Google Analytics View, which means you’ll have to make sure you have them on each of your Views.

A quick note on Views

Google Analytics is split up into Accounts, Properties and Views. Each Account has multiple Properties and each Property can have multiple views.

When you are using Google Analytics Filters, you are directly modifying the data that is going into each view. Once the data is modified, you can’t revert. So, I recommend setting up three Views in each Property. All Website Data (never has a filter applied to it), Testing and Primary Reporting.

You’ll never edit the All Website Data View, you’ll use the Testing View to update/edit any Filters or Goals you are setting up before applying the to the Primary Reporting View.

The Filters

Ok, once you have your three Views setup, lets get to applying Filters to your Testing View.

1. Block your own traffic

When you are the one testing all of your conversions to make sure they are being tracked, you can easily skew your data upwards. One of the easiest ways to solve this issue in your Reporting View is to exclude your workplaces IP address.

Once you hit Add New Filter, you’ll do:

1Custom -> Exclude -> IP Address -> your ip address

That should make sure that anything coming from your network is excluded from the View.

You can also switch out the exclude for an include to make sure that only your traffic is hitting your Testing view.

Testing: Confirm that you aren’t firing any page views by checking the Real Time section in Google Analytics. Once you know, switch off the exclude version from your Test view and add it to your Primary Reporting View.

2. Stop seeing localhost or staging.example.com

Another way to keep your test data away from that Primary View is to include only the traffic from your specific Hostname or Subdomain. Nike probably doesn’t want to see data from their testing.nike.com site (P.S. I totally just made up testing.nike.com, there is nothing there).

To implement this for your hostname do:

1Custom -> Include -> Hostname -> ^(www\.)?example\.com$

And for a subdomain do:

1Custom -> Include -> Hostname -> ^blogs\.exampleGlobal\.com$

Testing: You can test this one by going to your staging or development site and seeing if you’re traffic is popping up in the Real Time view.

3. Lowercase all the things

Imagine you are running facebook ads and just once you tag one with Facebook as the Source instead of facebook (notice the casing). That one ad will haunt you forever, not aggregating correctly in every report you make from now until the end of time. And it will probably mean you have to extract the data and work in a spreadsheet.

It sucks.

To fix this issue, you should lowercase pretty much as everything in your analytics setup. I recommend at least lowercasing:

  • Source

  • Medium

  • Campaign

  • Ad Content

  • Hostname

  • Request URI

  • Search Term

That seems like a lot, but they are pretty easy to implement. Follow this pattern for all of them.

1Custom -> Lowercase -> Source/Medium/Whatever

Testing: You can test this by throwing uppercase everything at your setup to see if it lowercases it. It’s a pretty easy one to do so you should be good.

4. Always see your hostname in your URL

I find this one useful to check up on if the filter above is working or not. It also helps a ton if you have different hostnames and subdomains all rolled up into one view.

It’s a little more complex, so I’ll explain it in more detail below.

Select Custom -> Advanced. You are going to see a bunch of extra fields, don’t panic.

Follow the steps below.

1Field A -> Extract A:
2
3Select Hostname
4
5Enter (.*)
6
7Field B -> Extract B:
8
9Select Request URI
10
11Enter (.*)
12
13Output To -> Constructor:
14
15Select Request URI
16
17Enter $A1$B1
18
19Select Field A Required
20
21Select Override Output Field

Testing: Now instead of seeing /page, you will see example.com/page.

5. Remove the query string from your URL

Since we are already grabbing all of the elements in the query string that we want (like source/medium) we can just remove those from the URI. This make things roll up and aggregate lot nicer.

This is another Custom -> Advanced so I’ll put the instructions for it below.

1Field A -> Extract A:
2
3Select Request URI
4
5Enter ^([^?]+)
6
7Output To -> Constructor:
8
9Select Request URI
10
11Enter $A1
12
13Select Field A Required
14
15Select Override Output Field

Testing: Check this over by adding a ?testing=testing to your URL and see if it pulls the query string off.

6. Make sure your URLs always roll up correctly

Request URIs can sometimes come with or without a / attached to the end. It’s another thing that can make it hard to roll pages up and do some aggregation on the metrics for pages. Making sure to add a / to the end of every URI makes this a lot easier and keeps everything clean.

Its a Custom -> Advanced and the instructions are below.

1Field A -> Extract A:
2
3Select Request URI
4
5Enter ^(/[a-zA-Z0–9/_\-]*[^/])$
6
7Output To -> Constructor:
8
9Select Request URI
10
11Enter $A1/
12
13Select Field A Required
14
15Select Override Output Field

Testing: Go check your Realtime data to see if any traffic is coming in to a page without a /. If that’s the case, somethings wrong.

Finishing up

If you follow the above Filters, your Views should be clean and easy to use. Hopefully this can keep you out of spreadsheets and inside Google Analytics more and more.

If you had any issues setting any of these up, feel free to comment or email me at colin@manifold.co. Always happy to chat.

Stratus Background
StratusUpdate

Sign up for the Stratus Update newsletter

With our monthly newsletter, we’ll keep you up to date with a curated selection of the latest cloud services, projects and best practices.
Click here to read the latest issue.