Lowercase Filter in Google Analytics 4 (GA4)
Loves Data
The filtering options in Google Analytics 4 are limited to excluding internal and developer traffic to your website, but what if you want to adjust the data being collected into your reports? How can you create a lowercase filter in GA4? Well, the good news is that you still can, but you will need to use Google Tag Manager.
The lowercase filter we’re about to create will modify all of the dimensions in GA4 that are based on the page path people view on your website. This means the filter we’re about to create will modify the following:
- Lowercase the ‘Page Path’, ‘Page Location’, and other page-based dimensions
- Lowercase the ‘Campaign Name’ or utm_campaign dimensions
- Lowercase the ‘Source’ or utm_source dimensions
- Lowercase the ‘Medium’ or utm_medium dimensions
- And any other dimensions that pull information from the URLs on your website
Okay, there are two steps to create a lowercase filter for Google Analytics 4. The first step is to create a user-defined variable in Google Tag Manager.
Step 1: Create a User-defined Variable
After opening your Google Tag Manager container, navigate to ‘Variables’ and click ‘New’ next to ‘User-Defined Variables’. Then create the following variable:
Variable Type: URL
Component Type: URL
Format Value: Change Case To… Lowercase
Step 2: Adjust the Page Location Parameter
The second step is to use the lowercase user-defined variable to send the lowercase version of your URLs to Google Analytics. We need to adjust the GA4 configuration tag in Google Tag Manager to do this. So you will need to navigate to ‘Tags’ and open your GA4 configuration tag.
Then you will need to select ‘Fields To Set’ for the tag, click ‘Add Row’, and adjust your tag so it looks like this:
Field Name: page_location
Value: {{Page URL | Lowercase}} or whatever you named your user-defined variable
Now you can save your tag and preview the changes using Tag Assistant. You will now find that ‘Page Location’ is lowercase in GA4, along with all of the dimensions that are based on the URLs of your website.
You can check everything is working by heading to Google Analytics and opening the DebugView (in the ‘Admin’ area) and by using the Realtime report.
Will the lowercase filter change query parameters?
Yes, this solution will lowercase the whole URL including any query parameters. This means if you have case-sensitive query parameters, like the GCLID parameter from Google Ads, then you will need to use a different solution.
If you’re running Google Ads campaigns, then you can try using the following code as a JavaScript variable. This will ensure the GCLID parameter isn’t changed to lowercase:
Comments