If you’ve been digging through your GA4 reports and noticed that the same page shows up as dozens (or even hundreds) of separate rows, you’ve likely found the culprit: query parameters. ?fbclid=..., ?utm_source=..., ?gclid=... — each unique URL gets its own line, and your clean page view data turns into a mess.
The good news? You can fix this. GA4 doesn’t have a built-in way to strip query strings, but Google Tag Manager does. That’s where the Trim Query variable template comes in.
Let’s get into it!
Why Query Strings Are a Problem in GA4
Here’s the scenario: you publish a page on your site, and it gets shared on social media, picked up by ads, and linked from a few newsletters. Each of those sources might add a query parameter — fbclid, gclid, utm_source, and so on.
In GA4, https://www.example.com/page?fbclid=abc and https://www.example.com/page?fbclid=xyz are treated as two different pages. Now multiply that by every combination of parameters and values, and your page report becomes… well, a headache to read.
The solution is straightforward: remove the query string (or at least the parameters you don’t care about) before the data reaches GA4.
Here’s the catch: GA4 doesn’t let you do this natively. You’ll need GTM for that.
How to Remove Query Strings with Trim Query in GTM
For example, let’s say you want to remove the fbclid parameter. That’s the one Facebook appends to your links when someone clicks through from their platform, and it’s a common culprit when your page URLs start multiplying like rabbits.
That’s where the Trim Query variable template in GTM comes in. It’s a community-built template that lets you specify exactly which query parameters to strip from the URL — and then use the cleaned-up version in your GA4 tags.
Step 1: Add the Trim Query Variable Template
First, open your GTM workspace and head over to Templates.
In GTM, click「Templates」——「Search Gallery」in Variable Templates, and search for “Trim Query”:
When you find it, click Add to Workspace. Once it’s imported, you’ll see it listed in your variable templates. That’s it — nothing complicated here.
Step 2: Create a Trim Query Variable
Now let’s put that template to use.
In GTM, click「Variables」——「New」——「Choose a variable type to begin setup…」——「Trim Query」,Then name it “Page URL (Remove Query String)” and make the following settings:
In the configuration, you’ll see a field where you can specify which query parameters to remove. For example, if you want to strip fbclid, enter it there.
By the way, you can list multiple parameters — just separate them with commas.
Step 3: Override page_location in Your GA4 Tags
At this point, you have a variable that outputs a clean URL. But GTM isn’t using it yet. You need to tell your GA4 tags to use this cleaned-up URL instead of the original one.
Open your GA4 Configuration tag (the one that fires on all pages). Configure Fields to Set as follows:
That’s the magic step. From now on, when this tag fires, it will override the page_location parameter with the cleaned URL.
Don’t forget to repeat this for any other GA4 event tags you have (like Purchase, Lead, etc.) if you want the parameter stripped everywhere.
Step 4: Preview and Publish
Never trust a tag configuration without testing it first. Here’s how to check that everything works:
Step 1:Click Preview in GTM.
Step 2:Enter a URL like https://www.bbccss.com?fbclid=PAAaYWoW in Tag Assistant:
Step 3:Uncheck “Include debug signal in the URL” and click “Connect”.
Once you’re in the debug view, click Container Loaded, then click on your GA4 tag. In the Values tab (top right corner), check the page_location field.
If it shows the URL without fbclid, you’re golden.
Final Words
Removing query strings in GA4 isn’t something you can do inside GA4 itself, but with GTM’s Trim Query variable template, it’s a quick fix. Just add the template, create the variable, and override page_location in your GA4 tags.
A word of caution: once this data is sent to GA4, you can’t go back and retroactively fix it. So make sure you genuinely don’t need that query parameter in your reports before you strip it out. When in doubt, keep it — you can always filter it out later in reports or Looker Studio.





