Stape
Search
Try for free

Why are UTM parameters removed, and how can you fix it?

Published
Nov 29, 2024

UTM parameters are crucial to tracking and analyzing marketing campaigns. These small snippets at the end of a URL help identify the source, medium, and campaign name, allowing marketers to track campaign performance.

Removing UTM parameters from URLs can significantly impact your marketing campaign's performance evaluation. In this article, we will consider why your UTM parameters can be removed and how you can fix this problem.

Why are UTM parameters so valuable?

UTM parameters are the most common and easy way to determine the traffic source and associated data. These parameters are added to the URL of your page when a user clicks on the link and contains the source data, for example, https://example.com?utm_source=google&utm_medium=cpc

In some platforms, UTM parameters are added automatically to the URL when clicked, while in others, you should add and configure them manually.

So, why are UTM parameters so important? The definition of the traffic source in Google Analytics 4 (as well as in most other analytics) is based on UTM parameters. Any problem with UTM parameters can cause increased unassigned traffic in Google Analytics.

Why can UTM parameters be removed?

Although UTM parameters do not contain personal data but only data about the source from where the user came to the site, some browsers (e.g., Safari, Brave) and plugins (e.g., uBlock) may truncate these parameters. They can be removed by default, or the user can activate such an option. This leads to inaccurate analytics performance. You won't get reliable data if many website visitors use such browsers or plugins.

How can you avoid UTM removal?

Most analytics platforms (including GA4) focus only on UTM parameters, and you can't replace them with other custom parameters to bypass the problem of UTM removal. 

But with the help of server-side tracking, you can transform your custom parameters back to UTMs. In this way, the browser won't be able to determine and remove the parameters from the URL. Thanks to such a transformation, your analytics platform will get the correct UTM parameters, allowing smooth data collection and providing accurate attribution.

Before starting

To configure the transformation of custom parameters to UTMs, you will need to:

  • Have a server GTM container. If you don't have one, check our guide on how to set up a server GTM container.
  • Set up events via server GTM and tracking for the chosen platform. In our article below, we are using GA4 as an example. However, the solution can be easily applied to any other platform.

How to configure server-side tracking to avoid UTM removal

Step 1: Come up with your unique UTM parameters replacement

You can use anything you like; we decided to use the following mapping for our example:

utm_source → st_src

utm_medium → st_mdm

utm_campaign → st_cmp

!

Note:

We recommend creating unique UTM parameter replacements and avoiding using short substitutions so that the transformation works correctly and doesn't affect other parameters in the requests.

Step 2: Use the new UTM parameters on your marketing platforms

Most marketing platforms allow you to manage UTM parameters. You just need to replace UTM parameters with the custom ones you created in the previous step.

For example, in Google Ads, you can do this in the Campaigns → Settings section and specify your custom parameters that will be added to the URL when clicked.

Campaign settings in Google Ads

Step 3: Make changes in the server GTM container

In GA4, UTM parameters are taken from the page URL (page_location in event data) where an event occurs.

So we need to configure transformation on the page_location event data parameter and transform our st_ parameters into utm_ parameters based on their value.

3.1 Add the Query Replacer variable template in your server GTM container

There are no in-built tools that can replace this data in server GTM, so you need to use a custom "Query Replacer" variable. You can download the Query Replacer variable on GitHub.

Add it to your server container. To do it, go to Templates → Variables → New → three dots in the top right corner → Import → select the .tpl file you downloaded → save changes.

Import template

3.2 Create a Query Replacer variable and configure it

Go to the Variables section of the server GTM container → next to User-Defined Variables, click "New" → select "Query Replacer" as Variable Configuration.

Create new variable

In the variable, you need to specify which parameters to replace with which ones.

In our example, it looks like this:

Query Replacer variable configuration

3.3 Create and adjust the UTM parameters transformation

To do it, go to the Transformations tab and create a new transformation.

Transformations in server GTM

As a transformation type, you need the "Augment event," which allows you to modify event data.

In the parameters, specify "page_location" and select the variable you created in the previous step as a value.

In the "Affected Tags" section, select the appropriate tags to apply only to GA4 tags.

In our example, it looks like on the screenshot below:

Transformation configuration

Test the configuration

Run container previews as usual (click "Preview") and check if everything works as expected.

Specify some test URLs with your fake UTM parameters, and check in preview mode that for the GA4 tag, the parameters are transformed.

Test the configuration

If everything is correct - publish the changes in the container.

After that, we recommend checking your traffic acquisition reports after a few days (in GA4, data can be processed for 24+ hours) to ensure no problems with them.

In case of difficulties with configuration, check our guide on debugging and monitoring server-side tracking configuration.

Conclusion

While UTM removal has not yet become a widespread issue and is not a default feature in most popular browsers, it poses a challenge for website owners targeting a "more tech" audience, who are more likely to use ad blockers and privacy-focused browsers.

If this issue affects you, implementing a UTM replacement solution is a handy and straightforward way to improve your analytics results significantly.

Try Stape for all things server-sideright now!