Categories
Website Tracking

How To Remove Query Strings From Page Path URL in GA4

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.

GA4 - Remove Querystrings From Page Path step 1

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.

GA4 - Remove Querystrings From Page Path step 2

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!).

By Jeroen

Jeroen Minks is a senior Google Ads & PPC consultant in Sydney with over 18 years of hands-on digital marketing experience.

As an experienced Google Ads & PPC freelancer, he specialises in high-performance Google Ads management and strategic PPC consulting for all types of advertisers.

Unlike a traditional Google Ads agency, Jeroen provides 100% transparency, no lock-in contracts, and direct access to senior expertise.

6 replies on “How To Remove Query Strings From Page Path URL in GA4”

Hi,
I think Dash means the url in the browser address bar. Is there a way to remove the query parameter there as well?

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.

Leave a Reply

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