Sub topic 4
Tagging Campaign Links with UTM Parameters
This chapter assumes you can open the GA4 Reports section, you know what a session and a campaign are, and you have at least Viewer access to a property that is collecting data. The next chapter covers how GA4 turns these values into the source, medium, and campaign dimensions. Here the focus is on building the links correctly and avoiding the mistakes that corrupt your reports.
Why tagging matters
GA4 can classify some traffic without help. It recognizes a click from a search engine, and it reads the referrer of a link from another website. It cannot know that a click came from your spring email newsletter, a partner's banner, or a QR code on a flyer. For that traffic the referrer is either missing or points to a generic place, such as a webmail site.
UTM parameters are query-string key-value pairs that you add to a destination URL. When a visitor lands on the page, the GA4 tag reads the parameters and stores them with the session. This lets you say exactly where a visit came from, in your own words.
The name comes from "Urchin Tracking Module", the product that Google Analytics grew out of. GA4 still reads these parameters, and they take priority over the referrer when both are present.
Anatomy of a tagged URL
A tagged URL is a normal URL with a query string appended. The tutorial's example:
https://www.example.com/pricing?utm_source=newsletter&utm_medium=email&utm_campaign=spring_saleThe parts are:
https://www.example.com/pricingis the landing page. Visitors see this page.?starts the query string.utm_source=newsletternames where the click came from.&separates each parameter from the next.utm_medium=emailnames the type of channel.utm_campaign=spring_salenames the campaign.
If the landing URL already has a query string, for example ?plan=pro, join your parameters to it with & instead of adding a second ?.
The parameters GA4 reads
GA4 recognizes five core parameters, plus a few for specific use cases.
| Parameter | Role | GA4 dimension it feeds | Example |
|---|---|---|---|
| `utm_source` | Where the traffic came from | Source | `newsletter` |
| `utm_medium` | The marketing channel type | Medium | `email` |
| `utm_campaign` | The named campaign | Campaign | `spring_sale` |
| `utm_term` | A paid keyword or audience label | Manual term | `running_shoes` |
| `utm_content` | Which ad or link variant was clicked | Manual ad content | `header_button` |
Three of these are the ones you should treat as required: source, medium, and campaign. Without a medium, the default channel group often cannot classify the visit, and it can fall into Unassigned. Without a campaign name, you cannot compare campaigns later.
GA4 also supports utm_id, which carries a campaign ID, and utm_source_platform, utm_marketing_tactic, and utm_creative_format. Use these only if you have a reason, such as importing cost data keyed on a campaign ID. They are optional.
How a tagged click becomes report data
The tag does the work at the moment of the visit. The sequence is:
Two consequences follow from this flow.
- The parameters must still be in the URL when the page loads. If a redirect strips the query string, GA4 never sees them.
- The tag must be installed on the landing page. Tagging a link to a page without GA4 records nothing.
Naming conventions
GA4 treats values as case-sensitive text. Email, email, and E-mail become three separate rows. A single inconsistency splits your numbers across rows, and it is difficult to repair after the data is collected, because GA4 does not let you rewrite processed data.
Agree on a convention before the first link goes out, and document it in a shared sheet. A workable set of rules:
- Use lowercase for every value.
- Use underscores instead of spaces. A space becomes
%20or+in the URL and looks messy in reports. - Keep values short but readable, such as
spring_salerather thanSpring Sale 2026 - Email Blast #2. - Choose from a fixed list of mediums. Reuse the same words across all campaigns.
- Do not put personal data, such as an email address, in any parameter. Google's policy prohibits sending personally identifiable information to Analytics, and URLs are visible in browsers and logs.
Mediums that match the default channel group
The default channel group classifies traffic using rules on source and medium. Choosing a medium the rules know about puts your traffic in the intended channel.
| Medium value | Typical use | Likely channel |
|---|---|---|
| `email` | Newsletters and mailers | |
| `cpc` | Paid search clicks | Paid Search |
| `paid_social` | Paid ads on social networks | Paid Social |
| `social` | Unpaid social posts | Organic Social |
| `display` | Banner ads | Display |
| `affiliate` | Affiliate partners | Affiliates |
| `referral` | Links on partner sites | Referral |
The exact rules depend on the source too. For example, a paid social medium is only classed as Paid Social when the source is a known social site. Check your property's channel group definitions in the next chapters before relying on a custom medium. A medium such as newsletter_blast that matches no rule can end up as Unassigned.
Building links without typos
Typing URLs by hand causes errors. Build them from a template instead. This short Python function applies the conventions above automatically.
from urllib.parse import urlencode, urlsplit, urlunsplit, parse_qsl
def tag_url(url, source, medium, campaign, content=None, term=None):
"""Return url with UTM parameters added, normalized to lowercase."""
def clean(value):
return value.strip().lower().replace(" ", "_")
parts = urlsplit(url)
query = parse_qsl(parts.query, keep_blank_values=True)
query += [
("utm_source", clean(source)),
("utm_medium", clean(medium)),
("utm_campaign", clean(campaign)),
]
if content:
query.append(("utm_content", clean(content)))
if term:
query.append(("utm_term", clean(term)))
return urlunsplit(parts._replace(query=urlencode(query)))
print(tag_url(
"https://www.example.com/pricing?plan=pro",
source="Newsletter",
medium="Email",
campaign="Spring Sale",
))The output keeps the existing plan=pro parameter and appends the tags:
https://www.example.com/pricing?plan=pro&utm_source=newsletter&utm_medium=email&utm_campaign=spring_saleThe same approach works in a spreadsheet formula. What matters is that one template produces every link.
Edge cases and common errors
Tagging internal links
Never add UTM parameters to links between pages of your own site. When a visitor clicks such a link, the new values overwrite the original source and start a new session. A visit that began from organic search is then credited to your homepage banner. Use separate event tracking, such as a select_promotion event, to measure internal promotions.
Redirects that drop parameters
Short links, link shorteners, and server redirects sometimes discard the query string. Test the final landing URL, not just the link you created. Open the link in a browser and check that the address bar still contains the utm_ values.
Auto-tagging and manual tags together
Google Ads uses auto-tagging, which adds a gclid parameter. If auto-tagging is on and the Ads account is linked to GA4, Google Ads data usually takes priority, and manual UTM values on those links are ignored. Do not hand-tag Google Ads links unless you have a reason and understand this behavior.
Case and spelling drift
A second person adds Email while you used email. The report now has two rows for one channel. Fix this at the source with a shared template and review of new values.
Session timeouts and repeat clicks
A tagged click starts a new session when the earlier session has ended, for example after 30 minutes of inactivity. A visitor who opens the same tagged link twice within one session does not create a second session, so click counts and session counts will not match.
Delay in reports
New campaign values can take up to about a day to appear in standard reports. Use the Realtime report to confirm that a test click arrives, then check the acquisition reports the next day.
A quick verification checklist
- The landing URL loads and shows the right page.
- The address bar still shows all
utm_parameters after any redirect. - Source, medium, and campaign are lowercase with no spaces.
- The medium belongs to your agreed list.
- The link is not used on your own site's internal navigation.
- The Realtime report shows the test visit with the expected source and medium.
Exercise
Your team sends a newsletter and tags the links utm_source=Newsletter&utm_medium=Email&utm_campaign=Spring Sale. A colleague sends a follow-up with utm_source=newsletter&utm_medium=email&utm_campaign=spring_sale. What problem will appear in GA4, and how do you prevent it?
Show answer
GA4 treats values as case-sensitive text, and the space becomes an encoded character. The two sends produce separate rows, such as Newsletter / Email and newsletter / email, and two campaign names, Spring Sale and spring_sale, so the totals are split. Prevent it with a written convention (lowercase, underscores, a fixed list of mediums) and a single link-building template used by everyone, such as the tag_url function.
Exercise
A banner on your homepage links to /pricing with utm_source=homepage&utm_medium=banner&utm_campaign=promo. Visitors who arrived from organic search now appear as sessions from homepage / banner. Why, and what should you do instead?
Show answer
UTM values on an internal link are read when the visitor lands on the next page. They start a new session and replace the original source. Remove the UTM parameters from internal links and measure the banner with an event such as select_promotion, which records the click without changing session attribution.