Sub topic 4
How GA4 Matches a Session to a Channel
Assume you understand sessions, events, and basic GA4 reports. You should also know that a URL can contain query parameters such as utm_source, utm_medium, and utm_campaign.
GA4 classifies a session by examining traffic dimensions. The main inputs are:
- Source: where the traffic came from, such as
google,newsletter, orpartner-site.com. - Medium: how the visitor arrived, such as
organic,cpc,email, orreferral. - Campaign: the marketing campaign connected to the visit.
A channel is a broader category created from those values. For example, google as the source and organic as the medium usually become the Organic Search channel.
The matching process
GA4 applies channel-group rules to the available source, medium, campaign, and advertising-platform data. A rule checks conditions such as:
- Whether the medium identifies paid advertising.
- Whether the source is a recognized search engine.
- Whether the source belongs to a social, shopping, or video platform.
- Whether the traffic came from an email link.
- Whether no usable campaign information exists.
The first applicable classification determines the channel. This means similar-looking traffic can receive different channels when one input changes.
| Source | Medium | Likely channel |
|---|---|---|
| `google` | `cpc` | Paid Search |
| `google` | `organic` | Organic Search |
| `newsletter` | `email` | |
| `partner-site.com` | `referral` | Referral |
GA4's complete rules contain many source lists and special cases. The table shows the general model rather than every production rule.
Why rule order matters
Some traffic can match more than one broad description. For example, a link from a search engine might be paid or organic. The medium usually resolves the difference:
google / cpcindicates paid search.google / organicindicates organic search.google / referralmay be treated as referral traffic because the medium does not identify search.
Campaign names alone do not normally make traffic paid. A campaign called summer_ads with no paid medium may not enter a paid channel. Use a consistent medium that describes the traffic type.
A simplified classifier
The following Python program models a few common rules. It is intentionally shorter than GA4's real rule set.
import re
SEARCH_SOURCES = {"google", "bing", "duckduckgo"}
PAID_MEDIUM = re.compile(r"^(.*cp.*|ppc|retargeting|paid.*)$")
def classify(source, medium):
source = (source or "").lower()
medium = (medium or "").lower()
if source == "(direct)" and medium in ("(none)", "(not set)"):
return "Direct"
if medium in ("email", "e-mail", "e_mail", "e mail"):
return "Email"
if source in SEARCH_SOURCES and PAID_MEDIUM.match(medium):
return "Paid Search"
if source in SEARCH_SOURCES or medium == "organic":
return "Organic Search"
if medium in ("referral", "app", "link"):
return "Referral"
return "Unassigned"
print(classify("google", "cpc"))
print(classify("newsletter", "email"))
print(classify("partner-site.com", "referral"))
print(classify("promo", "banner-x"))This prints Paid Search, Email, Referral, and Unassigned. The final result demonstrates an important point: values that do not match a recognized rule do not automatically become a useful marketing channel.
Exercise
What channel should a session with source google and medium cpc normally receive, and why?
Show answer
Paid Search, because google is a recognized search source and cpc identifies cost-per-click advertising.