GA4 - How to clean URL parameters
As we explained in this other blog post sometimes url parameters can give us big problems with cardinality in data and especially now in GA4.
Remember that in GA4 high cardinality of data can cause you to run into lines like this in your reports both defaults and scans:
Cardinality is the number of unique values assigned to a dimension. There are dimensions with a fixed number of unique values (e.g. Weekday, Device) and others can have a high cardinality (e.g. page path, transaction ID). If a dimension takes more than 500 values per day, it will be considered by GA4 as a high cardinality dimension.
One of google's recommendations to avoid encountering cardinality is to "Limit the collection of data especially those with high cardinality (Ex: URLs or url parameters)". Ya.
But you will agree that many times that cardinality in urls comes from external agents that do not depend on us and that also coincide with ad platforms... Do these url parameters sound familiar to you?
fbclid=oiekhakjdvnkajsd089237498
creative=luesfglknadsnadsnlad989867983
If you run ad campaigns on Google Ads or Meta they are sure to ring a bell
We are going to explain you a way to clean up all those parameters of the urls.
The first thing is to identify those parameters.
-
Create a new scan in GA4.
-
Add the page path + query string dimension and the views metric.
- Apply a filter to the table where the page path dimension contains "?", by default the table displays 10 rows, extend the table to 50 or 100 rows.
Now that you know what parameters you want to exclude you go to GTM to the container that manages that property:
-
Click on Templates and then Search Gallery.
-
In the gallery search engine type Trim Query and click on the solution that appears
-
Click on Add to Workspace
-
Click Add
Let's create a new variable:
-
Go to variables and click on create new.
-
Under variable type select Trim Query
-
Under target URL drop down and select Page URL. By default Queries is selected, if it is not, select this option.
-
In Add Row add one by one the parameters you want to clean up from the list extracted from GA4.
-
When you are done click Save.
And now let's apply this variable. You have two options:
- You go to each of the GA4 GTM tags and add a new parameter that overwrites the page_location with the variable you just created
- Create a new variable of type Tag Event Settings and apply it on all event tags .
And for the moment this is the best way to clean up those annoying urls that can also cause cardinality problems in reports.
And for the moment this is the best way to clean up those annoying urls that can also cause cardinality problems in reports.
If you want another day we will explain you how to clean this but in your Looker Studio reports.