How To Handle URL Query Parameters in Google Analytics

A url query parameter is any tag that comes after the question mark (“?”) at the end of page URL. These are separated by an ampersand (“&”). example.com/?utm_source=facebook&search_term=sample+query has two parameters, utm_source and search_term, with values “facebook” and “sample query”, respectively.

URL Query Parameters are a necessary evil in the world of Web Analytics. Used the right way, they help analysts and marketers track their web usage (and users) to glean helpful insights from traffic.

At the same time, they can cause some headaches. If you’ve ever looked at a raw Google Analytics page report, you know what I’m talking about. Tons of query pages make each page “unique” in your reports, and impossible to aggregate. Here’s what an unfiltered page report might look like:

url query parameters in google analytics

Some URL Query parameters, known as UTM Parameters, are easy to deal with. In fact, Google Analytics (and Adobe Analytics) handle the five default UTM parameters natively, with no work on your part. But what about all the rest? Google Analytics has a solution.

Cleaning URL Parameters in Google Analytics

There are three main categories I like to group URL query parameters into:

  1. UTM Parameters
  2. Search Parameters
  3. Other Parameters

Google Analytics makes it easy to clean your URLs of all of these, but you should know how to differentiate between them.

Clean UTM Parameters From Google Analytics

Trick question. UTM Parameters are automatically handled by Google Analytics. “UTM” actually stands for “Urchin Tracking Module” and is legacy from the Google Analytics predecessor Urchin. Now you know.

UTM Parameters are easily to identify. There are five of them, and they are all prefaced with “utm_”:

  1. utm_source
  2. utm_medium
  3. utm_campaign
  4. utm_content
  5. utm_term

Google will parse these out of your URLs and populate its reports with the values, no work on your end. Source/Medium, Campaign, and Content all tap into these UTM parameters. It’s useful to leverage these in your marketing campaigns. If you don’t already, you might want to learn more about UTM Parameters and use them to your advantage.

If you see an odd url query parameter that piggy-backs on the “utm_” naming convention but isn’t one of the Five, that’s okay! Just treat it as a Custom URL Parameter (see below).

Site Search Query Parameters

Site Search can be a valuable tool to researching customer pain points or SEO opportunities for your website. Most bootstrapped templates and WordPress blogs have site search capability built in, but you have to tell Google Analytics that you’re interested in the data. Depending on your CMS or search platform, your search URLs could be a little different.

First, make sure you have a Filtered View in Google Analytics. We’re going to be updated View settings, so we want to leave the master, raw data view alone as a backup. Done? Good.

Now, let’s identify a Site Search URL and the associated query parameters. At the beginning of this post, I used this example URL:

https://www.example.com/?utm_source=facebook&search_term=sample+query

In this scenario, we can easily identify the search query parameter as search_term. Remember that.

site search query parameters

Now, go into your Google Analytics Filtered View and click “View Settings”. Scroll down a bit. You’ll pass a field titled “Exclude URL Query Parameters”. We’ll come back to that. Scroll to the section titled “Site Search Settings” and toggle it on. Insert the search_term query parameter we just identified, and click the checkbox to “Strip query parameters out of URL.” This will take the value of your query parameter (“sample query” in our example) and drop it in the Site Search section of Google Analytics, all while removing the query parameter from your page reports.

You can also toggle the Site Search Categories to “On” and do the same with other search-related query parameters. This can help you drill further into your Site Search Reports, should you need to.

Other URL Query Parameters

Any url query parameters that haven’t been handled above need one of two things: exclusion, and/or custom dimensions.

The Custom Dimension route is great if you have useful data in those extra query parameters. This is a slightly more advanced process that deserves its own blog post. For now, read about using Google Tag Manager to store URL parameters.

Still, most other URL query parameters are going to be unnecessary for your purposes. Other websites, especially on Social Media, like to tack these on for their own traffic. You’ll just want to toss them and forget about them. How do you do this?

Remember that “Exclude URL Parameters” section we saw above? We’ll use that. In your Filtered Google Analytics View, return to View Settings. In the Exclude URL Parameters box, add your rogue url parameters in a comma-separated list. Common parameters you might want to ditch include ref, fbclid, and gclid. Scour your page reports for the mess. You’ll likely need to update this list over time.

Exclude URL Query Parameters

And there you go! Once all your rogue url query parameters are in this Exclude box, save all your changes. The URLs in your Filtered View page reports should all be pretty from here on out.

Leave a comment

Your email address will not be published. Required fields are marked *

%d bloggers like this: