Sub topic 5
Tagging Campaign Links with UTM Parameters
This chapter assumes you know what source, medium and campaign are in GA4, and that you have seen the default channel list. Here you will learn how to build campaign URLs that land in the channel you intend, and how tagging mistakes cause misclassification.
Why tagging decides the channel
GA4 does not know which of your links came from a newsletter or a paid ad. For any traffic that isn't tagged, it only has the referrer, the address of the page the visitor came from. UTM parameters let you state the source, medium and campaign yourself, in the link. They are the main way to control classification for traffic you pay for or send yourself, such as email, SMS, partner placements and social ads.
A UTM parameter is a query-string key that starts with utm_. GA4 reads these keys from the landing page URL when a session starts. You do not configure anything in GA4 to turn this on.
Classification then happens in two steps:
- GA4 reads
utm_source,utm_mediumandutm_campaignand stores them as the session's source, medium and campaign. - The default channel group rules evaluate those stored values and pick a channel.
Your tagging therefore feeds directly into the rules covered in the previous chapter. A wrong medium gives a wrong channel.
The parameters GA4 reads
| Parameter | Maps to | Notes |
|---|---|---|
| `utm_source` | Session source | Where the traffic comes from, such as `newsletter` or `google`. |
| `utm_medium` | Session medium | The kind of traffic, such as `email` or `cpc`. This has the strongest effect on the channel. |
| `utm_campaign` | Session campaign | The name of the promotion. |
| `utm_id` | Campaign ID | An identifier that is useful for importing cost data. |
| `utm_term` | Manual term | Usually a paid keyword. |
| `utm_content` | Manual ad content | Separates variants of an ad or link. |
| `utm_source_platform` | Session source platform | Optional extra detail about the platform. |
Source, medium and campaign are the three you should always set. The others are optional detail.
Two worked examples
The first link is a newsletter promotion. Because the medium is email, GA4 places sessions from it in the Email channel.
https://www.example.com/spring-sale?utm_source=newsletter&utm_medium=email&utm_campaign=spring_sale_2026The second link points at the same landing page but is tagged for a paid search ad. A search source such as google combined with a paid medium such as cpc is the pattern GA4 treats as Paid Search.
https://www.example.com/spring-sale?utm_source=google&utm_medium=cpc&utm_campaign=spring_sale_2026Only the source and medium changed. The landing page and the campaign name are identical, but the sessions are reported in different channels. Comparing the two channels' results for one campaign is a quick way to see how each channel performs.
Choosing medium values that match the rules
The medium is the value most likely to be wrong, because the default rules match it against fixed names. The table lists common mediums and the channel each normally produces. The channel conditions are simplified, since some channels also check the source.
| Your traffic | Suggested medium | Typical channel |
|---|---|---|
| Email campaign | `email` | |
| Paid search ad outside Google Ads | `cpc` with a search source | Paid Search |
| Paid social ad | `paid_social` or `cpc` with a social source | Paid Social |
| Organic social post you tag yourself | `social` | Organic Social |
| Banner or display ad | `display` or `banner` | Display |
| Affiliate partner | `affiliate` | Affiliates |
| Link on a partner site | `referral` | Referral |
| Text message | `sms` | SMS |
The exact lists live in Google's channel group definitions, which change over time. Check the current definitions before you adopt a naming scheme, and test a sample link in the Realtime report or DebugView.
Here is the pattern for the paid channels. A medium that matches a paid pattern (roughly cpc, ppc, retargeting, anything starting with paid, or anything containing cp) makes the session paid only when the source is also recognized as a search or social site. If the source is unknown, the session usually ends up in Paid Other, or in Unassigned when the medium is not paid either. Inventing a medium like banner-x is the most common way to end up in Unassigned.
Building links safely with a script
Hand-typed links produce inconsistent values. A small helper can normalize them and keep any parameters already on the URL, including the fragment. This script uses only the standard library.
import re
from urllib.parse import urlsplit, urlunsplit, parse_qsl, urlencode
def slug(value):
value = value.strip().lower()
return re.sub(r"[^a-z0-9_-]+", "_", value).strip("_")
def tag_url(url, source, medium, campaign, content=None, term=None):
required = {"source": source, "medium": medium, "campaign": campaign}
missing = [name for name, value in required.items() if not value]
if missing:
raise ValueError("missing required UTM values: " + ", ".join(missing))
parts = urlsplit(url)
query = [(k, v) for k, v in parse_qsl(parts.query, keep_blank_values=True)
if not k.startswith("utm_")]
tags = [("utm_source", source), ("utm_medium", medium),
("utm_campaign", campaign), ("utm_content", content),
("utm_term", term)]
for name, value in tags:
if value:
query.append((name, slug(value)))
return urlunsplit((parts.scheme, parts.netloc, parts.path,
urlencode(query), parts.fragment))
print(tag_url("https://www.example.com/spring-sale",
"Newsletter", "Email", "Spring Sale 2026"))
print(tag_url("https://www.example.com/spring-sale?ref=nav#pricing",
"google", "cpc", "Spring Sale 2026"))The first line printed is the newsletter link from the example above. The second keeps ref=nav and puts the #pricing fragment after the query string, where it belongs. The helper removes any utm_ keys already on the URL so a link is never tagged twice.
Rules for consistent tagging
Follow these habits so that reports stay readable:
- Use lowercase everywhere. GA4 reports treat
Emailandemailas different values in the source, medium and campaign dimensions. Even where channel rules tolerate case differences, your campaign reports will split into duplicate rows. - Use underscores or hyphens instead of spaces. Spaces become
%20or+and make values harder to read and match. - Keep a shared list of approved mediums and sources, and treat it as a controlled vocabulary. A shared spreadsheet or a script like the one above works.
- Put the campaign name in
utm_campaignonly. Do not repeat the source or medium inside it. - Put dates or versions in the campaign name only when you intend to compare them, such as
spring_sale_2026. - Use
utm_contentto separate links within one campaign, such asheader_buttonandfooter_link, rather than creating many campaigns.
Where tagging goes wrong
Tagging internal links
Do not add UTM parameters to links between pages of your own site. The parameters carry a new source, medium and campaign into the data, which can replace the original traffic source with your own tag and distort attribution. Use event parameters to track clicks on internal banners instead.
Parameters lost in redirects
Some link shorteners, login flows and redirects drop the query string. When the landing page URL has no utm_ keys, GA4 cannot read them. Open the final URL in a browser after following the redirect and check that the parameters survived. A tagged link whose sessions show as Direct or Referral is a typical sign of this.
Auto-tagged Google Ads traffic
If your Google Ads account is linked and auto-tagging is on, the click carries a gclid parameter that GA4 uses to fill in source, medium and campaign. By default this takes priority over manual UTM values on the same link, so do not add UTM tags to Google Ads destination URLs unless you have a reason and have checked the override setting. Auto-tagging is covered in the next chapter.
Wrong parameter order or placement
The query string starts with ?, parameters are joined with &, and a fragment (#section) must come after the query. A fragment placed before the ? hides the parameters from the server and from GA4.
Case and typo variants
utm_medium=emial is valid tagging as far as GA4 is concerned. It will be stored faithfully and classified as Unassigned. Scan the Session medium dimension periodically for near-duplicates.
Checking that a tagged link works
- Open the tagged link in a private browser window so no earlier session interferes.
- Open the Realtime report and look for your visit. Check the source and medium shown.
- After processing time (standard reports can lag by a day), add the Session default channel group dimension to a report and confirm the sessions are in the expected channel.
- If they are not, compare the stored medium with the table above, then check for redirects that stripped parameters.
Exercise
A team tags a banner ad as utmsource=homepagepartner&utmmedium=banner-x&utmcampaign=Spring Sale. Sessions appear under Unassigned. Name two problems with the tagging and give a corrected link for https://www.example.com/offer.
Show answer
First, "banner-x" is not a medium the default rules recognize (Display expects values such as display or banner), so no channel rule matches and the session becomes Unassigned. Second, the campaign "Spring Sale" has a capital letter and a space, which causes duplicate rows and encoded characters in reports. A corrected link is https://www.example.com/offer?utmsource=homepagepartner&utmmedium=display&utmcampaign=spring_sale
Exercise
A paid search ad on Bing is tagged utmsource=bing&utmmedium=cpc&utmcampaign=brandterms, but you want it counted as Email. Would changing only utm_campaign fix it? What should change instead?
Show answer
No. The campaign name does not affect the channel in the default rules. The medium and source do. The ad is paid search traffic, so it should stay in Paid Search. If the traffic is really email, change the medium to email and use a source such as newsletter. Otherwise leave the tagging as it is.