Analytics

How to Exclude Query String Parameters from Google Analytics Reports

Clean up your Google Analytics page reports for improved attribution reporting and analysis by excluding useless query parameters.

How to Exclude Query String Parameters from Google Analytics Reports

Brad Redding

Brad Redding is the Founder & CEO of Elevar. Specializing in analytics, tracking, GTM, and conversion optimization.

Do you ever look at page reports in Google Analytics and wonder why you have so many seemingly duplicate URLs that look something like this:

  • /?mc_cid=1243234
  • /?mc_cid=1342&mc_eid=32342
  • /?src=12343&mc_cid=9fda9
  • /?SID=1235343dfgsdf3

And you’re left scratching your head wondering why all of these links lead to your homepage with the same content?

Or how about checkout:

  • /checkout/contact_information?refresh_count=1
  • /account/login?checkout_url=/22255559/checkouts/9d537cc4c9d7985a1abd0cf7f9ced84b?step=contact_information
? and &

Are query parameters that append to the end of your base URLs.

Where Do Query Parameters Come From

If you are active in digital marketing and utilize email, affiliate, display, or referral marketing then you have likely seen this in your reports. You’ll even see these from native eCommerce platform configurations.

Example: ?SID is a Magento session ID where ?refresh_count is a Shopify query parameter in checkout steps.

Generally speaking, there are two primary functions of query parameters:

  1. Query parameters that change the content on the page (think sort by on category pages or ?variant=123xyz for changing the selected product on a product page)
  2. Query parameters that push data back to another data source without changing the content on the page

Using the previous homepage example: mc_cid and mc_eid are from Mailchimp and automatically appended to links within emails that you send out. These help push email reporting data back into Mailchimp (opens, clicks, etc).

This is generally the same for other digital marketing platforms as well like Doubleclick, Facebook, etc.

You’ll want to focus on cleaning up query parameter type # 2 since these don’t provide much value in Google Analytics reporting analysis.

Related: How to fix the trailing slash causing duplicate page URLs in Google Analytics

Why Do Query Parameters Cause Problems

These generally don’t hurt your website per se, they just cause messy analytics reports when you’re attempting to analyze data in bulk. Here’s an example of a page report that has multiple rows of data even though it’s technically the same page:

query parameters in google analytics

Now if you’re trying to analyze/compare page performance in bulk then pages affected by these query parameters will not have an accurate roll up amount and you will have to add these up manually (no thanks!).

How to Fix Page Reports by Excluding Query Parameters

This is pretty simple and can be accomplished in a few different ways:

  1. Create a custom advanced filter that will look for all ? and & query parameters and filter these out automatically
  2. Utilize the native “Exclude URL Query Parameters” configuration in your Google Analytics View Settings (preferred)

Option 1: Create Filter to Exclude All Query Parameters

This is done through a Search and Replace filter that you can set on your view.

Please be sure to implement this on a Test view first!

Here is what the filter looks like:

remove-query-params

Once you save – that’s it! All query params will now be removed in your row report data.

Option 2: Use Exclude Query Parameters Config Setting

You can find this setting in Google Analytics > Select Your Main View > View Settings:

exclude url query parameter setting

Here you’ll include all of your query parameters that you’d like to exclude from reports.

IMPORTANT: This will not exclude the page URL from being recorded in Google Analytics, this will simply remove these query parameter values from your URLs so they roll up to the actual URL.

Example:

  • /collections/dresses – 500 pageviews
  • /collections/dresses?mc_cid=123431 – 3 pageviews
  • /collections/dresses?mc_cid=34323431 – 7 pageviews

Will then look like this for future hits:

  • /collections/dresses – 510 pageviews

Remember that this setting does not go back and update historical hits, this will only clean up future page hits.

If you have any questions or issues updating this setting in your Analytics account drop a comment below.

Related Articles:

More Google Analytics Tips

Sign up to receive our latest posts on Google Analytics, eComm, and Optimization.

We respect your inbox.

  1. Very informative. Thanks for sharing. One question, is there a list of common Shopify query parameters and what they do?

    Trying to figure out what ones to potentially exclude when setting up Google Analytics for a shopify site.

    Thanks in advance.

    1. Hi Will,

      Thank you for the note!

      ?variant is really the only big Shopify parameter that you’ll see (which you don’t want to exclude). Email is usually the biggest one that you’ll see this from. If you go to your behavior > page report and then set a filter that excludes page with ?variant and includes any page wit ? you should see any that might need excluding for you.

      Let me know if that helps!

  2. Thanks Brad, that’s interesting.

    Variant is one I was aware of and I thought I would want to exclude it?

    The thought being that I’m setting up a site for retailing clothing and there will be several variants of each clothing article. For example, for the same shirt you’ll be able to buy a white one, a black one, a grey one, and a pink one and also in multiple sizes for each color. I thought I’d want to exclude variant so that Google Analytics doesn’t record separate URLs for each color + size variant? I’d want GA to aggregate all that data under one URL?

    In my mind it’s all one page, the customer is just picking a color and size on the page. But it sounds like according to your experience I shouldn’t exclude variant in such a case?

    Is variant used for something else too or maybe I’m misunderstanding the value of / reason for not excluding variant?

    As far as when you say “Email is usually the biggest one that you’ll see this from.” – do you mean Email is usually the biggest one that has query parameters I might want to exclude? Such as in your MailChimp examples in the article?

    Sorry, I’m just a little unsure what “Email is usually the biggest one that you’ll see this from” referrers to – variant or to something else given your MailChimp example?

    Last, after posting my original question I found a forum post that recommended considering excluding the following parameters for Shopify. So far I haven’t been able to figure out what these parameters actually do and if it’s a good idea to exclude them (I’m still setting the site up so the behavior page report doesn’t have any info yet):

    q – this one I know is for search queries and I have set it up with site search tracking in GA. However, I’m not sure if it also should be considered for Exclude URL Query Parameters? Or would doing that mess up the site search tracking? Or maybe it’s valuable to see the data for different pages based on the different customer searches / values for q?

    The others I saw listed are:
    bis_id
    checkout_url
    contact_posted
    cache
    refresh_count
    preview_key

    I’m not sure what these ones do and if they should be excluded.

    Thanks again for the help. Much appreciated.

  3. Brad, I see you recommend not excluding “variant” from the query parameters on a Shopify site.

    Is there a reason why variant should not be excluded? Does it hurt remarketing – for example not showing the correct shit color the customer saw on the site? Or maybe variant is used for other purposes as well? Something else?

    I thought, for example, on a Shopify site selling apparel where there are multiple colors and sizes of an item excluding variant would make sense? This way Google Analytics wouldn’t show multiple rows of data for the same item that only varied by color and size? But maybe there’s another reason?

    Thanks I appreciate the help.

    1. Hi Will,

      Great question and point. Honestly – the variant part is subjective. I probably lean towards your suggestion (excluding ?variant parameters) since you can get the variant specific data through enhanced ecomm reports.

      Great suggestion.

      Brad

  4. Hey Brad, thanks for this!
    I’ve applied the Config setting but it doesn’t appear to work for funnel steps in goals. I’ve got a goal with:
    step 1 (use a calculator)
    step 2 (get calculator results)
    step 3 (get a quote)

    Step 2 has parameter values in the url (to pass on the results to step 3). For example:

    /novated-lease-calculator-results?carType=1&driveAwayPrice=30000&leaseTerm=3&kmsPerYear=10000&grossSalary=60000&businessUse=0

    I have only entered
    /novated-lease-calculator-results as the page to hit in our step 2. I can’t be more specific than that because the parameter values change.

    Is there a way to use regex or another way to have step 2 fire? Would really appreciate any help or advice!

Leave a Reply

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

You may also like