What is a Query Parameter in Google Analytics?

Cody Schneider8 min read

Seeing URLs in your Google Analytics reports cluttered with question marks and strange codes can be confusing. These additions, called query parameters, can seriously bloat your reports and make it difficult to understand how your content is truly performing. This article will walk you through what query parameters are, how they impact your data, and most importantly, how to clean them up for more accurate reporting in Google Analytics 4.

GraphedGraphed

Still Building Reports Manually?

Watch how growth teams are getting answers in seconds — not days.

Watch Graphed demo video

What Are Query Parameters?

First, let's break down the structure of a typical URL. Everything after the question mark (?) in a URL is a query parameter. It's a way for websites to pass bits of information back and forth. A URL with query parameters consists of a key-value pair, linked by an equals sign (=), and multiple parameters are separated by an ampersand (&).

It looks like this:

www.yourwebsite.com/products?category=shoes&size=10

In this example:

  • The base URL is www.yourwebsite.com/products.
  • The first parameter key is category with the value shoes.
  • The second parameter key is size with the value 10.

These parameters are incredibly useful. They tell the website what content to show (like search results or filtered product pages) or tell your analytics tool where users came from (like a specific email newsletter or advertising campaign).

Why They Create Problems in Google Analytics

The main issue is that Google Analytics, by default, treats every unique URL as a separate page. This means it might see these three URLs as three different pages, even though they all display the exact same blog post:

  • yourwebsite.com/blog/great-article
  • yourwebsite.com/blog/great-article?utm_source=newsletter
  • yourwebsite.com/blog/great-article?sessionid=xyz123abc

This leads to "data fragmentation." Instead of seeing 10,000 views for your one great article, your report might show 3,000 views for the first URL, 5,000 for the second, and 2,000 for the third. This makes your reports messy and makes it nearly impossible to analyze the performance of a single piece of content accurately. Cleaning this up gives you a single, unified view of each page's performance.

GraphedGraphed

Still Building Reports Manually?

Watch how growth teams are getting answers in seconds — not days.

Watch Graphed demo video

Common Types of Query Parameters

Not all query parameters are bad. Some are essential for tracking, while others are just noise. The key is knowing which is which before you start removing things.

1. Tracking Parameters (Keep These)

These are the parameters you use to measure the effectiveness of your marketing. You do not want to remove these from your URLs before the data gets to Google Analytics, as GA is specifically designed to read them.

  • UTM Parameters: utm_source, utm_medium, utm_campaign, utm_content, and utm_term. These tell you where your traffic came from. GA automatically processes these and puts the data into your Traffic Acquisition reports.
  • Advertising Click IDs: gclid (Google Ads), fbclid (Facebook Ads), msclkid (Microsoft Ads). These auto-tagging parameters are used by advertising platforms to pass detailed campaign data into GA. They are essential for measuring ad performance.

2. Site Functionality Parameters (Consider Removing)

These parameters change the content on the page, like sorting a list or filtering products. They often provide little analytical value and are prime candidates for exclusion.

  • Session IDs: sessionid=, sid=. These are used by some websites to track a user's session. They are unique for every visit and are a major cause of data fragmentation.
  • Filtering & Sorting: sort=price_ascending, filter=blue. Common on e-commerce category pages, these parameters create multiple versions of the same page in your reports.
  • Pagination: page=2, p=3. If you have multi-page articles or category listings, these can fragment your data across several "pages."
  • Miscellaneous Parameters: Sometimes CMS plugins, third-party widgets, or internal redirects add their own parameters (e.g., print=true, ref=internal). These usually don't offer value and can safely be removed.

3. Site Search Parameters (Handle with a Special Setting)

Parameters like q=, s=, or search_term= are used when someone uses the search bar on your website. You don’t want to remove these in the same way. Instead, you should tell GA what they are so it can populate your Site Search reports with valuable data on what your users are looking for.

Finding Active Query Parameters in Your GA4 Reports

Before you can clean up your data, you need to find the parameters that are causing problems. It's a quick process in Google Analytics 4.

  1. Navigate to Reports > Engagement > Pages and screens.
  2. By default, the table shows the dimension "Page title and screen name." Click the drop-down arrow and change this primary dimension to "Page path and screen class." This will show you the URL paths instead of just page titles.
  3. In the search box just above the table, type a question mark (?) and press Enter.

This will filter the report to show only the URLs that contain query parameters. Now you can scroll through the list to identify the parameters that are appearing frequently and decide which ones need to be excluded.

GraphedGraphed

Still Building Reports Manually?

Watch how growth teams are getting answers in seconds — not days.

Watch Graphed demo video

How to Exclude Unwanted Query Parameters in GA4

In Universal Analytics, there was a simple text box in the View Settings where you could list parameters to exclude. Google Analytics 4 has changed how this works, and the process is now a bit more technical, typically handled through Google Tag Manager (GTM).

Warning: Be careful with this process. Removing the wrong parameter can break your marketing attribution or other important tracking. Go slowly and double-check your work. Never remove UTM parameters or advertising click IDs. If GTM is new to you, you may want to have a developer help with this.

The general idea is to modify the page_location field that GA4 uses, stripping out unwanted parameters before the data is sent to Google's servers. Here is a simplified approach using GTM.

Step 1: Create a Variable to Hold the Clean URL

This variable will use a tiny bit of JavaScript to grab the current URL and strip away everything from the ? onward. This effectively cleans all query parameters.

  1. In your Google Tag Manager container, go to Variables in the left-hand menu.
  2. Under "User-Defined Variables," click New.
  3. Name your variable something clear, like "JS - Clean Page URL."
  4. Click Variable Configuration and choose Custom JavaScript as the variable type.
  5. In the code box, paste the following snippet:

function() { return window.location.protocol + "//" + window.location.hostname + window.location.pathname, }

  1. Click Save.

Note: This basic code strips all parameters. For more advanced setups where you need to keep certain parameters (like UTMs coming from a QR code redirect an app might have generated), you would need more advanced JavaScript. For most users, this simplified approach works best because GA4 generally processes critical attribution parameters before your GTM tag logic would interfere.

GraphedGraphed

Still Building Reports Manually?

Watch how growth teams are getting answers in seconds — not days.

Watch Graphed demo video

Step 2: Update Your GA4 Configuration Tag

Now, you need to tell your main GA4 tag to use this new, clean URL for the page location instead of the default full URL.

  1. In GTM, navigate to Tags and find your main "Google Analytics: GA4 Configuration" tag. Click to edit it.
  2. Under Configuration Settings, click "Add parameter" in the Fields to Set section.
  3. For the Field Name, type page_location.
  4. For the Value, click the Lego block icon and select the "JS - Clean Page URL" variable you just created.
  5. Click Save on your tag.

Step 3: Preview, Test, and Publish

Before making your changes live, it's absolutely essential to test them.

  1. Click the Preview button in the top right of GTM.
  2. Enter your website's URL (including a query parameter you want to strip) and click Connect.
  3. When your website loads in the new tab, navigate back to the Tag Assistant preview tab.
  4. Select your GA4 Configuration Tag from the timeline on the left.
  5. In the tag details, check the value for page_location. It should be the clean URL, with the parameters removed. Also, check the data being sent to Google Analytics using the GA Debugger Chrome Extension or the GA4 DebugView to ensure everything looks correct.
  6. Once you've confirmed it's working as expected, go back to GTM and click Submit to publish your changes.

Keep in mind that this change only applies to data moving forward. It will not retroactively clean up the messy data already in your GA4 reports.

Final Thoughts

Managing query parameters is a small but critical step toward maintaining clean, reliable, and actionable data inside Google Analytics. By identifying useless parameters that fragment your data and setting up a system to exclude them, you can build reports that accurately reflect your content's performance and give you the clear insights you need.

This process of cleaning up query parameters highlights a larger challenge: data from different marketing and sales platforms (like Google Analytics, Facebook Ads, Shopify, or Salesforce) often needs manual intervention to make sense. At Graphed, we've designed our platform to do this heavier lifting for you. We connect to all your sources, automatically handling the complexities behind the scenes, so you get clean, real-time dashboards instantly. Instead of getting tangled in GTM settings, you can ask a question in plain English like "how many views did my latest blog post get?" and Graphed will give you the answer without you ever needing to worry about a "sessionid".

Related Articles

How to Enable Data Analysis in Excel

Enable Excel's hidden data analysis tools with our step-by-step guide. Uncover trends, make forecasts, and turn raw numbers into actionable insights today!