Sub topic 7
Measuring organic sessions and engagement in GA4
This chapter shows how to count organic sessions and measure engagement in GA4 so you can compare them with the Search Console click data from earlier chapters. It assumes you know what a GA4 event, a session and an ecommerce revenue field are. It also assumes you can read basic SQL and run pandas code.
Search Console tells you what happened on the results page. GA4 tells you what happened after the click. Both views matter for AI Overviews. A click can fall without a change in rankings, and the visitors who still click may behave differently from before.
What GA4 can answer in this study
GA4 cannot tell you whether a visit came from a query that showed an AI Overview. It sees the visit only after the click. Its role in this study is narrower:
- Count organic sessions per landing page and per day.
- Measure the quality of those sessions: engagement rate, engaged time and conversions.
- Provide the session base that revenue is attached to in the next chapter.
You link GA4 to Search Console through the landing page. Search Console reports page and GA4 reports landing_page. Pages are the shared key, so you analyse GA4 by page group (for example, pages whose top queries were exposed) instead of by query.
How GA4 decides a session is organic
GA4 assigns each session a channel grouping from its source and medium. A session is "Organic Search" when the medium is organic and the source is a recognised search engine. Three details cause most errors.
- Source and medium are set per session. In BigQuery they appear as
collected_traffic_sourceon events and astraffic_sourceon the user. Do not rely on the user-level field, because it records the first acquisition of the user and not the current session. - Google organic is not the only organic. Bing, DuckDuckGo and others also have the medium
organic. If your question is about Google AI Overviews, filter the source togoogleas well. - Referrals from AI products are different. Visits from chat assistants usually arrive with a referral medium. They are not organic search and do not belong in this baseline. Keep them in a separate channel so a rise there is not mistaken for a recovery in organic.
The query in the topic plan filters on a medium event parameter. That works only if your implementation sends it. In many properties the reliable fields are collected_traffic_source.manual_medium and collected_traffic_source.manual_source. Check which fields are populated in your own export before trusting a count.
SELECT
collected_traffic_source.manual_source AS source,
collected_traffic_source.manual_medium AS medium,
COUNT(*) AS session_starts
FROM `project.analytics_123456.events_*`
WHERE event_name = 'session_start'
AND _TABLE_SUFFIX BETWEEN '20260101' AND '20260331'
GROUP BY source, medium
ORDER BY session_starts DESC
LIMIT 20;Run this once before you build anything else. If google / organic is missing or most rows are NULL, fix the definition now. Every later number depends on it.
Defining a session correctly
GA4 has no session ID that is unique across users. A session is identified by the pair of user_pseudo_id and the ga_session_id event parameter. The query in the topic plan builds this pair and counts distinct combinations, which is the right approach. Counting rows of session_start events is close, but it can overcount when a session is restarted or events are duplicated.
The ga_session_id value is a timestamp of the session start in seconds. Two different users can have the same value, so never group on it alone.
Engagement metrics
GA4 defines an engaged session as one that lasts at least 10 seconds, or has a conversion event, or has at least two page or screen views. These are the default thresholds, and the 10-second one can be changed in the data stream settings. Engagement rate is engaged sessions divided by all sessions. It replaces the old bounce rate, which is now simply 1 minus the engagement rate.
The BigQuery export marks engagement with the session_engaged event parameter (value '1' when the session was engaged) and records engagement_time_msec on events. The next query computes per-day organic Google sessions, engaged sessions and total engaged time.
WITH events AS (
SELECT
PARSE_DATE('%Y%m%d', event_date) AS day,
user_pseudo_id,
(SELECT value.int_value FROM UNNEST(event_params) WHERE key = 'ga_session_id') AS session_id,
(SELECT value.string_value FROM UNNEST(event_params) WHERE key = 'session_engaged') AS engaged,
(SELECT value.int_value FROM UNNEST(event_params) WHERE key = 'engagement_time_msec') AS engagement_msec,
collected_traffic_source.manual_source AS source,
collected_traffic_source.manual_medium AS medium
FROM `project.analytics_123456.events_*`
WHERE _TABLE_SUFFIX BETWEEN '20260101' AND '20260331'
),
sessions AS (
SELECT
day,
user_pseudo_id,
session_id,
MAX(IF(source = 'google' AND medium = 'organic', 1, 0)) AS is_google_organic,
MAX(IF(engaged = '1', 1, 0)) AS is_engaged,
SUM(IFNULL(engagement_msec, 0)) AS engagement_msec
FROM events
WHERE session_id IS NOT NULL
GROUP BY day, user_pseudo_id, session_id
)
SELECT
day,
COUNT(*) AS sessions,
SUM(is_engaged) AS engaged_sessions,
SAFE_DIVIDE(SUM(is_engaged), COUNT(*)) AS engagement_rate,
SAFE_DIVIDE(SUM(engagement_msec) / 1000, COUNT(*)) AS engaged_seconds_per_session
FROM sessions
WHERE is_google_organic = 1
GROUP BY day
ORDER BY day;Grouping by day as well as by the session pair means a session that crosses midnight is counted on each day it appears. For a daily trend this is a small effect. If it matters, take the day of the session's first event instead.
Working with the result in pandas
Export the query result and look at the weekly trend. Weekly totals smooth out the weekday pattern that most sites have.
import pandas as pd
# `daily` is the result of the engagement query above, loaded as a DataFrame.
daily = daily.copy()
daily["day"] = pd.to_datetime(daily["day"])
weekly = (
daily.set_index("day")
.resample("W-SUN")[["sessions", "engaged_sessions"]]
.sum()
)
weekly["engagement_rate"] = weekly["engaged_sessions"] / weekly["sessions"]
print(weekly.round(3))Recompute the rate from the summed counts. Averaging the daily rates gives busy and quiet days the same weight, which biases the result.
What to expect under AI Overviews
Two effects can appear at once, and they push in different directions.
- Fewer sessions. If answers on the results page replace some clicks, organic sessions to the affected pages fall. This is the effect Search Console CTR already shows.
- Different sessions. The people who still click may be those who need more than the summary. Engagement rate and engaged time per session can go up even as total sessions go down. A rising engagement rate on its own is therefore not good news. It may only mean the casual visitors have gone.
Because of this selection effect, compare sessions and engagement together, and compare them for the same page groups you used in the Search Console cohorts. A per-session metric can improve while total engaged time, the number that reflects the amount of value delivered, still falls.
Tracking changes that can mimic an effect
GA4 numbers can shift because of the measurement setup rather than visitor behaviour. Before you attribute a change to AI Overviews, check these:
| Change | Typical symptom |
|---|---|
| Consent banner or consent mode update | Sessions drop across all channels on the deployment date |
| Tag moved or broken on a template | Sessions drop on one page type only |
| Engagement threshold edited | Engagement rate jumps without any change in behaviour |
| Domain or URL structure change | Landing pages split into old and new paths |
| Channel grouping rules edited | Organic sessions move to or from other channels |
Write down the date of every analytics change in a log. The next chapters use these dates when they rule out confounders. A useful check is to compare direct and total sessions around the change date. A fall in organic that matches a fall in every other channel points to tracking, not search.
A practical checklist
- Confirm that the source and medium fields identify Google organic in your export.
- Count sessions with the user and session ID pair.
- Build page groups that match your Search Console cohorts.
- Report sessions, engaged sessions and engaged time, never only a rate.
- Review the log of analytics changes for the study window.
Exercise
A page group shows organic sessions down 20% after an AI Overview appeared on its main queries, but engagement rate rose from 58% to 66%. A colleague says this proves the Overview sends better visitors and that the traffic loss is not a concern. What is wrong with that conclusion, and what would you compute instead?
Show answer
Engagement rate is a ratio, so it can rise when low-intent visitors stop clicking, even if the Overview did not improve anyone's experience. It says nothing about total value. Compute engaged sessions (sessions multiplied by engagement rate) before and after: 100 × 0.58 = 58 becomes 80 × 0.66 ≈ 53, so engaged sessions still fell by about 9%. Then compare the same figures for a comparison page group over the same dates, and check the analytics change log, to see how much of the drop belongs to the Overview rather than to seasonality or tracking.
Exercise
Why does the engagement query group events by userpseudoid and gasessionid together, and why does the weekly pandas step recompute engagement rate from summed counts?
Show answer
gasessionid is only a start timestamp, so two users can share a value, and only the pair identifies one session. Recomputing the rate from summed engaged sessions and summed sessions weights each session equally. Averaging daily rates would give a quiet day the same weight as a busy day and distort the weekly figure.