Introduction
If you’ve started analyzing GA4 data in BigQuery, you’ve likely come across the field:
traffic_source.medium
It looks simple at first. However, in the context of Consent Mode, user stitching, and multi-touch attribution, its meaning and behavior deserve a deeper look.
In this post, I’ll break down:
- What
traffic_source.mediumactually represents in GA4 - How it differs from the old
mediumfield in Universal Analytics - When and why it might be
null - How to model it properly in BigQuery when attribution breaks
Let’s get into it.
What Is traffic_source.medium?
In GA4 BigQuery export, traffic_source.medium refers to the channel or delivery mechanism that brought the user to your site or app during their first recorded visit (or session).
Examples:
"organic"– from a search engine"referral"– from another website"cpc"– paid ad click"email"– email campaign"none"– direct traffic (no referral)
You’ll find it under this structure:
event_params.traffic_source.medium
Or, when unnested in your BigQuery SQL:
traffic_source.medium
How Is It Populated?
GA4 automatically populates traffic_source.medium using:
- UTM parameters (
utm_medium) - Referrer logic
- gclid and ad attribution
It reflects the first known session’s acquisition data, and it doesn’t update for later visits — unless you explicitly track custom attribution.
Why Is traffic_source.medium Sometimes Null?
If you’re seeing null values in BigQuery for this field, it’s likely due to:
1. Delayed Consent
In Consent Mode, users may initially reject tracking. If consent is granted after the session begins, GA4 may not have captured the acquisition data for that session.
2. Missing UTM Parameters
If a marketing campaign didn’t use UTM tags, GA4 may default to direct or null.
3. User Session Stitching Failure
If you’re analyzing user behavior across multiple sessions or devices, and haven’t stitched them yet (e.g., using COALESCE(user_id, user_pseudo_id)), you might be looking at partial journeys with missing attribution.
How to Handle Null medium Values in BigQuery
Here’s a SQL technique you can use to recover or model traffic_source.medium:
FIRST_VALUE(traffic_source.medium IGNORE NULLS) OVER (
PARTITION BY user_pseudo_id
ORDER BY event_timestamp
) AS modeled_medium
This approach pulls the first known non-null medium for a user, even if consent was delayed. It works great as a fallback in your attribution queries, like the one we built in attribution model here..
Bonus Tip: Comparing Raw vs Modeled Medium
You can even track how much data you’re recovering with modeled attribution:
SELECT
COUNTIF(traffic_source.medium IS NULL) AS null_medium_count,
COUNTIF(modeled_medium IS NOT NULL) AS recovered_medium_count
FROM your_modeled_table
This helps quantify the impact of Consent Mode on your source/medium data — and lets you explain modeling tradeoffs clearly in stakeholder reports.
Related Posts
TL;DR
| What | Why It Matters |
|---|---|
traffic_source.medium | Captures how a user first arrived (e.g., organic, cpc) |
Can be null | Consent delay, no UTMs, or user not stitched properly |
Fix with FIRST_VALUE() | Recover attribution by modeling from earliest known session |
| Use in modeling | Essential for consent-aware, privacy-respecting attribution |
Up Next
Tomorrow, we’ll pull together everything we covered this week — session stitching, attribution logic, SQL tips, and traffic_source.medium — into a downloadable SQL cheatsheet for your GA4 projects.

