About the Blog

Its about anything and everything. I, Steven Hancock started this blog for a variety of reasons. I want to start documenting my life and sharing that with others, whether that's family, friends, strangers or my future self. I also want to start sharing my experiences with others in hopes that others can learn from me. Perhaps I can help someone set up an Ubuntu server, write a Django Web Application, or setup a Phonegap Mobile App.

That's it. I'm hear to share. Nothing more, nothing less. I will be covering a wide variety of topics so feel free to browse for the blog entries that interest you most.

Google Analytics Filtering Query Strings

February 21, 2015

Ooo look, my Google Analytics property has filled up with thousands of unique pages! Finally people are starting to navigate through my extensive website and give me the attention I deserve. I can literally feel the masses consuming, digestion, and soaking up all the knowledge that I have bestowed onto the world.

Wait… how come there isn't a single page that has more than a couple views? And why are all of these "unique pages" some sort of derivative of my homepage?





As you've probably guessed this is just a case of a single page being shown by Google Analytics as multiple pages. GA does this because many site engines use query string parameters (the stuff that comes after the question mark in a URI) as a way of identifying what page, or parts of a page, to load. Take for instance an e-commerce site that displays all items in a uniform way and uses the item query parameter as an indicator for which item to load. So http://www.somewebsite.com/catologue?item=123 is a different page then http://www.somewebsite.com/catologue?item=345. Most websites aren't made this way anymore to take advantage of SEO... and maybe google may want to rethink their default settings. But who cares? I'm going to tell you how to easily fix it anyway.

I Got Two Ways For You

The Easy Way

From the Google Analytics Administration console create a new view from an existing property and then select View Settings. Simply place the query parameters that you would like to ignore in the Exclude URL Query Parameters textbox separated by a comma (this field is case sensitive).

Google Analytics Exlude URL Query Parameters

As an aside, when messing around with views you always want to create a new view. View settings are applied directly to the view and data is only collected that match your settings. So if you mess up, there is no going back to the main view. So always have at least two views, one that has no settings, and one that has your customized settings.

The Other Easy Way

There is an equally easy way using filters. Use this option if you don't know which query parameters you will be ignoring and you just want to ignore them all. Once again, create a new view on your GA property. Select Filters and create a new one. Create a new Custom Filter Type that uses Search and Replace to filter the Request URI using ^([^\?]+)\?.* as the Search String.

Google Analytics Filter - Exclude Query

You could also use a similar approach for a solution to genericise a URI like http://www.somewebsite.com/account/23456/overview, where 23456 is the accountId.

Just In Case You Were Worried

If you use a lot of UTM parameters for different links to your website, rest assured, that Google Analytics still captures the UTM parameters the same way as they did before you set up your view or filter settings.

Ready to Go

Google Analytics will now start collecting data with your new configuration. Hurah! But don't get too mad if you look at your view and you don't see any results. GA applies your new settings only to NEW data. So if you create a new view, that view will be empty until new visitors start accessing your site. If you modified an existing view, only new page loads will have the new settings applied to their recorded data.