If you upgraded your Google Analytics to GA4 there’s a big chance that you are seeing some query strings in your reporting.
Within the GA4 reporting, there is only an option to show your URLs as “Page path + query string and screen class”. Within Universal Analytics, you might have excluded some query strings and parameters from the URL (for example Facebook’s FBCLID parameter).
July 2023 Important Update:
By now, Google has added a function called “page path and screen class” to their reporting.
If you drill down to the standard Life cycle report in GA4 and go to Engagement > Pages and screens you can select Pages path and screen class. This option makes it unnecessary (in most cases) to remove the parameters from the reporting.
If you still want to remove the parameters from GA4 you can follow the steps in this article.
Removing parameters from GA4
GA4 does not give an option to filter out query strings on the account level.
Luckily, you will be able to do this via Google Tag Manager.
Step 1: Add a custom javascript to GTM
As a first step, you will need to add a custom javascript to your Google Tag Manager.
Go to “Variables” and create a new “User-Defined Variable”. Select “Custom JavaScript” as a Page Variable and copy the following code.
function(){
return document.location.hostname + document.location.pathname;
}See below what this will look like.

Step 2: Update your GA4 tag
Then, jump into your GA4 tag. Go to “Tags” and select the appropriate tag.
Within “Fields to set” add a row with the Field Name “page_location”. As the value, select the Javascript you just created.

Step 3: Publish your changes
Don’t forget to publish your GTM changes. This will remove any query strings and parameters from your reporting going forward (it won’t change any of your previous data!).

6 replies on “How To Remove Query Strings From Page Path URL in GA4”
Is there a way to change the URL that people see?
Hi Dash,
What do you mean with that?
Hi,
I think Dash means the url in the browser address bar. Is there a way to remove the query parameter there as well?
Hi Meret,
This is not something you can control in GTM or GA4 unfortunately.
At the end of the article, it says that the URL parameters would be removed from reporting. Does this mean that the URL parameter data is still sent to Google Analytics? With the previous version of Google Analytics, we were able to modify the location sent in the script with the Google Analytics code to prevent that information from being sent to Google Analytics in the first place. Thanks.
Hi Sarah,
If you follow the steps in this article the parameter is not being sent to Google Analytics as it’s being removed before the tracking code is fired.