Sub topic 2
Where GA4 gets traffic source data: UTM parameters and channel groups
This chapter assumes you can navigate GA4 reports, know what a key event (conversion) is, and have seen a URL with utm_ parameters. Every attribution model works on traffic source data, so the credit a model assigns can only be as accurate as the source labels it receives. The chapter covers where those labels come from, how GA4 turns them into channels, and where they go wrong.
The three layers of traffic source data
GA4 records where a visit came from in three layers:
- Raw signals. The page URL (including
utm_parameters and click IDs such asgclid) and the HTTP referrer, which is the page the visitor came from. - Source, medium and campaign. Values GA4 derives from those signals. Source is where the visit originated (
google,newsletter). Medium is the type of channel (organic,cpc,email). Campaign is the name of the marketing effort. - Channel group. A rule-based bucket such as Paid Search or Email, computed from source and medium.
Attribution reports and models consume layers 2 and 3. Mistakes made in layer 1 flow into every report after it.
UTM parameters
UTM parameters are query string fields you add to a link to tell GA4 how the click should be labeled. This is the example landing page URL for a newsletter campaign:
https://www.example.com/spring-sale?utm_source=newsletter&utm_medium=email&utm_campaign=spring_saleGA4 reads these into the session's source (newsletter), medium (email) and campaign (spring_sale).
| Parameter | Role | Typical example |
|---|---|---|
| `utm_source` | Where the traffic comes from | `newsletter`, `facebook` |
| `utm_medium` | The marketing channel type | `email`, `cpc`, `social` |
| `utm_campaign` | Campaign name | `spring_sale` |
| `utm_term` | Paid keyword | `running_shoes` |
| `utm_content` | Distinguishes ads or links | `header_banner` |
| `utm_id` | Campaign ID, used for data import | `cmp_1042` |
Source, medium and campaign are the three you should always set. GA4 also accepts a few extra parameters, such as utm_source_platform and utm_marketing_tactic, but most channel rules only look at source and medium.
Building tagged links safely
Tagging by hand invites typos. This script builds a URL and encodes values correctly. It also lowercases them, for the reason explained in the pitfalls section below.
from urllib.parse import urlencode, urlsplit, urlunsplit
def tag_url(base_url, source, medium, campaign):
params = {
"utm_source": source.strip().lower(),
"utm_medium": medium.strip().lower(),
"utm_campaign": campaign.strip().lower().replace(" ", "_"),
}
parts = urlsplit(base_url)
return urlunsplit((parts.scheme, parts.netloc, parts.path,
urlencode(params), parts.fragment))
print(tag_url("https://www.example.com/spring-sale",
"Newsletter", "Email", "Spring Sale"))
# https://www.example.com/spring-sale?utm_source=newsletter&utm_medium=email&utm_campaign=spring_saleWhat GA4 does with the signals
When a visitor lands on your site, GA4 decides the traffic source roughly in this order:
- If the URL has a Google Ads click ID (
gclid) and the property is linked to Google Ads with auto-tagging, GA4 uses the Google Ads data for source, medium and campaign. By default this takes priority over manual UTM values. The Google Ads link has a setting that lets manual tagging override auto-tagging. - Otherwise, if the URL has
utm_parameters, GA4 uses them. - Otherwise, if there is a referrer that is not on your referral exclusion list, GA4 records the referrer's domain as the source. The medium is
organicif the referrer is a known search engine, andreferralotherwise. - If none of these apply, the visit is recorded as
(direct) / (none).
Two behaviors in this flow matter for attribution:
- Direct is a fallback, not a measurement.
(direct) / (none)means GA4 found no usable signal. The visitor may have typed the URL, or a stripped referrer, a dropped parameter or a redirect may have hidden the real origin. The next chapters cover how attribution models treat these visits. - A new campaign does not start a new session in GA4. In Universal Analytics, a change of campaign began a new session. GA4 does not, so a returning visitor with a new UTM tag inside the 30-minute session window is still the same session. Session-level source can then differ from what you tagged. The dimension scopes chapter returns to this.
Default channel groups
A channel group is a set of rules that sorts traffic into named channels by looking at source, medium and a few other fields. GA4 ships with a Default channel group that includes channels such as Direct, Organic Search, Paid Search, Organic Social, Paid Social, Email, Referral, Display, Affiliates, Organic Video, Paid Video and Cross-network. Anything that matches no rule lands in Unassigned.
The rules are fixed and Google maintains them. These are the ones you meet most often:
| Condition on source and medium | Channel |
|---|---|
| Source `(direct)` and medium `(none)` or `(not set)` | Direct |
| Medium is `email` | |
| Medium matches `cpc`, `ppc` or `paid*`, and source is a known search site | Paid Search |
| Medium matches `cpc`, `ppc` or `paid*`, and source is a known social site | Paid Social |
| Medium is `organic` and source is a known search site | Organic Search |
| Medium is `referral`, `app` or `link` | Referral |
Rules depend on both fields, so a wrong medium breaks the channel even when the source is right. This toy classifier mimics the idea. It is a simplified illustration, not the real rule set.
SEARCH_SITES = {"google", "bing", "duckduckgo"}
SOCIAL_SITES = {"facebook", "instagram", "linkedin"}
def default_channel(source, medium):
source, medium = source.lower(), medium.lower()
if source == "(direct)" and medium in {"(none)", "(not set)"}:
return "Direct"
if medium == "email":
return "Email"
paid = medium in {"cpc", "ppc"} or medium.startswith("paid")
if paid and source in SEARCH_SITES:
return "Paid Search"
if paid and source in SOCIAL_SITES:
return "Paid Social"
if medium == "organic" and source in SEARCH_SITES:
return "Organic Search"
if medium in {"referral", "app", "link"}:
return "Referral"
return "Unassigned"
for s, m in [("newsletter", "email"), ("google", "cpc"),
("facebook", "paid_social"), ("facebook", "social"),
("(direct)", "(none)")]:
print(f"{s} / {m} -> {default_channel(s, m)}")Running it prints Email, Paid Search, Paid Social, Unassigned and Direct. The facebook / social line shows a common failure. A medium of social does not match the paid rule, and in this toy it matches no organic social rule either. The real default group has an Organic Social rule, but a medium you invent, such as fb_post, falls through to Unassigned.
Custom channel groups
If the default rules do not match how your business thinks about marketing, you can create a custom channel group in Admin under Data display, then Channel groups. You write your own conditions on source, medium, campaign and similar fields, and rules are evaluated in order, so put specific rules before broad ones. Custom groups are useful for splitting brand and non-brand campaigns, or for separating a partner program from general referrals. Check which reports and explorations accept a custom group before relying on it. Attribution reports use the default channel group, so treat the default rules as the standard when comparing models.
Common pitfalls
- Case sensitivity.
Email,emailandEMAILappear as three separate mediums in reports. Pick lowercase and enforce it, as the builder script does. - Inventing mediums. Use mediums the default rules know (
cpc,email,organic,referral,paid_social,affiliate). Custom mediums land in Unassigned. - Tagging internal links. UTM parameters on links inside your own site start a new source for the visit and overwrite the real one. Use UTMs only on inbound links.
- Auto-tagging conflicts. If Google Ads links carry both
gclidand UTMs, the Google Ads values usually win, and your manual labels never appear. - Lost referrers. Redirects, payment gateways and some apps strip the referrer. Add payment domains to the unwanted referrals list so a returning shopper is not relabeled as a referral from the gateway.
- Parameters dropped by redirects. A redirect that discards the query string turns a tagged click into a direct visit.
Why this matters for attribution
Each touchpoint in a conversion path (the next chapters define these) carries a source, medium and channel. Last-click gives all credit to the final non-direct touchpoint's channel. The data-driven model compares paths that include different channels. If sources are mislabeled, both models credit the wrong channel. Unassigned and Direct inflate when tagging is poor, and the models cannot recover information that was never recorded.
Exercise
A paid Facebook ad links to your site with ?utm_source=facebook&utm_medium=Paid-Social&utm_campaign=Spring_Sale. Reports show two rows for the same ad, one with Paid-Social and one with paid_social. Give two reasons this hurts attribution and one convention that fixes it.
Show answer
First, GA4 treats the values as separate case-sensitive strings, so the same ad's conversions are split across rows and any one row understates the channel. Second, Paid-Social is not a medium the default channel rules recognize (they expect forms like paid_social), so those visits may fall into Unassigned and receive no credit under Paid Social in attribution reports. A fix is a documented convention: all lowercase, only recognized medium values such as paid_social, and underscores instead of hyphens or spaces, ideally enforced by generating links with a script or template.