Categories
Web analytics Latest articles

Google Tag Manager Variables: How to Capture UTM Parameters

August 2026 update: The original article was published in 2016. The core idea still applies, but the GTM interface has changed, additional UTM parameters have been introduced, and, most importantly, we now use GA4 instead of Universal Analytics.

Here is the most important update right at the beginning: if you only want to see campaigns in GA4, you do not need custom UTM variables in GTM. GA4 will process supported parameters from the destination URL automatically, provided that the landing-page URL containing those parameters is passed to the measured event in page_location. Redirects that remove UTM parameters, or a custom override of page_location that omits them, will change the result. You should therefore create a variable only when you need to work with its value directly in GTM.

Do you even need a UTM variable in GTM?

Often, you do not. It depends on what you want to do.

  • I only want campaign reports in GA4: do not create a custom variable. For standard reporting, it is enough for GA4 to receive the correctly tagged landing-page URL in page_location on the first relevant event.
  • I want to fire a tag or run a check based on the campaign: use the native URL variable.
  • I want to pass UTM parameters to another system: a URL variable can read the value, but check the purpose, consent requirements, and whether the destination system actually needs the parameter.
  • I want to use the value on subsequent pages: the URL variable alone is not enough. Once the UTM parameters disappear from the address, the variable can no longer find them.

{{Page URL}} or {{Click URL}}?

Both are built-in GTM variables, but they read from different sources and should be evaluated on different events.

URL sourceWhat it readsWhen to use it
{{Page URL}}The address of the currently open pageOn page load or after a completed virtual page change in an SPA
{{Click URL}}The address of the link the user clickedOn a link-click event

No jQuery, no library, and no Custom JavaScript. This part of the original article still applies.

Which UTM parameters GA4 recognizes

The basics remain the same: source, medium, and campaign. However, Google’s current documentation also describes additional parameters.

ParameterPurposeExample
utm_sourceTraffic sourcenewsletter
utm_mediumMarketing mediumemail
utm_campaignCampaign namesummer_sale
utm_idA stable campaign ID that can also be used for cost data importscmp_2026_08
utm_source_platformThe platform responsible for directing the trafficsearch_ads_360
utm_termA keyword or another campaign termrunning_shoes
utm_contentDistinguishes between creatives or linkshero_button
utm_creative_formatCreative formatvideo
utm_marketing_tacticMarketing tacticremarketing

utm_source describes a specific traffic source, while utm_source_platform can identify the platform that manages media buying or traffic routing. This is why the official example is Search Ads 360 rather than simply another newsletter name.

Important: At the time of this update, Google states that utm_creative_format and utm_marketing_tactic are not reported in GA4. The fact that you can add them to a URL or read them in GTM does not mean that you will get a ready-made dimension for them in the interface.

For a standard manually tagged campaign, use at least utm_source, utm_medium, and utm_campaign. Add any other parameters that have a clearly defined purpose in your measurement plan. Values are case-sensitive. Meta and meta can split a single platform into two rows, so it is practical to use lowercase values, consistent separators, and a centralized naming convention.

In GA4, look for campaign information in the acquisition dimensions. UTM parameters are intentionally not stored in the Landing page + query string or Page path + query string dimensions; the complete address is available in the Page location dimension. Because supported parameters and reporting behavior can change, it is worth checking the primary documentation regularly. The overview of where to find up-to-date information about web analytics and GA4 can also help.

Example of a tagged URL:

https://www.example.com/offer?utm_source=newsletter&utm_medium=email&utm_campaign=summer_sale

How to get the value of utm_source in GTM

For this purpose, GTM provides a native user-defined URL variable that can expose individual parts of an address, including a query parameter.

  1. Open Variables in GTM.
  2. Under User-Defined Variables, select New.
  3. Select URL as the variable type.
  4. Select Query as the component type.
  5. Enter utm_source as the query key.
  6. Leave the URL source set to the current page, or explicitly use {{Page URL}}.
  7. Name the variable, for example, url.page.utm_source.
  8. Save it and check the result in Preview mode.

Create additional variables for the other parameters in the same way, changing only the query key:

  • url.page.utm_medium
  • url.page.utm_campaign
  • url.page.utm_id
  • url.page.utm_source_platform
  • url.page.utm_content
  • url.page.utm_term

Do not automatically create a variable for every UTM parameter that exists. Add only those that are used by a specific trigger, validation check, or destination tag, and document their purpose in the measurement plan.

You can then use the variable in a trigger, a lookup table, or as an input to a tag. However, do not send the same UTM parameters to GA4 again as custom parameters merely because they are available. GA4 already has its own acquisition logic for them, and additional copies only make the data more complicated.

Bonus: UTM parameters from a clicked link instead of the current page

The original article conflated the URL of the open page with the URL of an element. Today, it is better to name these two things separately.

To read a parameter from the link the user has just clicked, create another URL variable, but set {{Click URL}} as its source. The component type remains Query, and the key could be, for example, utm_campaign. The article about measuring link clicks in Google Tag Manager covers click tracking in more detail.

A name such as url.click.utm_campaign will remind you six months later that you are not reading the address of the current page. Check the variable on the click event; during the initial page load, no clicked link exists yet.

This approach makes sense when auditing outgoing links or checking their tagging. Do not use it as a substitute for measuring internal navigation elements. For internal banners, product lists, and promotional placements, GA4 provides recommended ecommerce events and parameters, such as view_promotion and select_promotion.

Limitations, common errors, and performance impact

The variable only sees the current URL

On the landing page, it might return newsletter. After the user navigates to a page without UTM parameters, there is nothing left for the variable to read. GA4 processes its acquisition information independently, but your custom GTM variable is not a storage mechanism. If you need the value later in your own system, design its storage deliberately, with a clear purpose, retention period, and consent rules.

Do not put UTM parameters on internal links

UTM parameters describe the campaign that brought a user to the website. Adding them to internal links can distort event-level attribution and overwrite the meaning of acquisition values. According to the traffic-source processing rules, GA4 does not start a new session because of a new campaign in the middle of a visit, but it can associate the new values with the events on which it received them. For internal placements, use a parameter that describes the actual internal context instead.

The query string belongs before the fragment

Correct:

https://www.example.com/offer?utm_source=newsletter#pricing

Incorrect:

https://www.example.com/offer#pricing?utm_source=newsletter

Redirects must not discard parameters

Test the entire path from the advertising or newsletter link to the final URL on which the Google tag loads. In addition to UTM parameters, preserve every parameter that your deployed advertising and measurement systems genuinely use, and maintain their list in the measurement plan. Depending on your implementation, this may include gclid, dclid, and gclsrc, gbraid, wbraid, and gad_*, or the cross-domain linker parameter _gl.

For a one-off microsite, the older practical example of forwarding UTM parameters from a landing page to another domain can also be useful. However, it is not a universal replacement for correctly configured cross-domain measurement and preservation of the _gl parameter.

An SPA needs the correct event

In a single-page application, the URL can change without a new document load. You should therefore evaluate the variable only on an event that represents a completed virtual page change. With manual measurement, update the URL first and only then send the virtual page_view with the correct page_location. The official guide to measuring SPAs with GTM provides further details.

Duplicate, empty, and encoded values

A URL can contain the same key more than once, an empty value, or malformed encoding. When query parameters are read in the standard way in GTM, the first value is used for a repeated key. The GTM API can also retrieve all values when explicitly requested. However, do not treat a UTM parameter with a duplicated key as a legitimate multi-value parameter. It is a tagging error that your tests should catch.

Use %20 for spaces. If a literal plus sign is part of the value, encode it as %2B; an unencoded + is ambiguous in query strings. Do not allow malformed sequences, such as a standalone % or an incomplete %2, into production campaign tagging.

Will it slow down the website?

A native URL variable does not traverse the DOM, download a library, or send its own network request. A few such variables have a negligible performance impact. The bigger problem is usually container clutter: dozens of duplicate variables, unclear names, and tags that use them without documentation.

UTM parameters, privacy, and sensitive data

A URL is not a secure vault. It can appear in browser history, server logs, referrer information, and analytics data. Google therefore explicitly requires that URLs and parameters sent to Analytics do not contain personally identifiable information.

Never include the following in UTM parameters:

  • an email address;
  • a telephone number;
  • a name or username;
  • a customer ID that can be used to identify a person directly;
  • sensitive information about health, finances, or another private situation.

Google Analytics provides redaction of email addresses and selected query parameters for web data streams. Treat this as a safeguard, not as your main form of protection. A correctly designed campaign must remove personal data from the URL at the source.

When you send a value outside GA4 using your own tag or a third-party tag, verify the purpose, recipient, and firing conditions. Google Consent Mode is a helper, not a substitute for consent: according to the official guide, it adjusts the behavior of supported Google tags, but it does not automatically grant consent to an arbitrary custom tag.

How to test the setup

  1. Start Preview mode in your GTM workspace and connect the website through Tag Assistant.
  2. Load a test URL containing lowercase values and all the core UTM parameters.
  3. On the page-load event, verify the values of the URL variables you created.
  4. Go through the edge cases in the table below. Do not check only whether the variable returns “something”; verify that the result is exactly what you expect.
  5. Follow any redirects and verify the final address, including UTM parameters, the advertising identifiers you use, and any _gl parameter.
  6. For an SPA, test both the initial load and a second virtual page, and check the order in which the URL changes and the page_view is sent.
  7. If you use {{Click URL}}, verify the variable on the click event rather than on the initial page view.
  8. In the request sent to GA4, check the page_location that was actually transmitted. Then verify data collection in Realtime or DebugView, and later in the Traffic acquisition report.
Test queryExpected value of url.page.utm_sourceAssessment
?utm_source=newsletternewsletterValid basic scenario
?utm_medium=emailNo value; Preview mode may display undefinedThe tag must not send the literal string undefined
?utm_source=An empty valueTagging error; do not pass the empty value on
?utm_source=newsletter&utm_source=partnernewsletter, which is the first valueTagging error; remove the duplicate key
?utm_source=czech%20newsletterczech newsletterThe encoded space is readable, but a value without spaces is preferable in production
?utm_source=partner%2Baffiliatepartner+affiliateThe literal plus sign is encoded unambiguously
?utm_source=partner%2The result must not be treated as a valid campaign valueEncoding error; the test must fail

Test the error cases as well. The most attractive screenshot from a single ideal URL is not proof that your campaign tagging is resilient.

Summary

  • GA4 can process supported UTM parameters without custom GTM variables, provided that it receives them in the correct page_location.
  • If you need a value in GTM, use the native URL variable and create variables only for parameters that have a specific use.
  • Distinguish between the page URL, {{Page URL}}, and the clicked-link URL, {{Click URL}}.
  • UTM parameters are not intended for internal links or personal data.
  • The greatest risk is not performance, but inconsistent naming, lost parameters, and poorly tested edge cases.

The super-simple and super-effective solution remains. Today, however, you need to understand not only how to create the variable, but, more importantly, why you are creating it and exactly what you expect it to do.

Related articles

.