Analyses of A/B tests and quasi-experiments often fail at a step that comes before the statistics: the session definition. GA4's ga_session_id is convenient and not wrong, but it is designed for general reporting, not for isolating the exposure to and outcome of a specific intervention.
The problem lies in where GA4 draws session boundaries. A user who leaves the site, browses elsewhere and returns within 30 minutes stays in the same GA4 session. When measuring the effect of an on-site banner, that off-site detour is a potential confounder that should be isolated, not absorbed. GA4 also does not start a new session when the campaign source changes, and a late server-side event can be attached to the preceding session.
In BigQuery, sessions can instead be built with window functions over the raw event stream, typically as a dbt model. Three kinds of rule are worth combining: a time gap chosen for the question (for example 10 minutes of inactivity rather than 30); event triggers, such as a new campaign source opening a new session or a purchase closing one so that post-purchase activity is not credited to the same conversion; and explicit user identification rules.
The mechanics are simple. Compute the gap to the previous event with LAG(event_timestamp) (remembering that event_timestamp is in microseconds), flag a boundary when the gap exceeds the threshold or a trigger event occurs, and number sessions with a running SUM() of those flags over PARTITION BY user_pseudo_id ORDER BY event_timestamp. Each rule is versioned and testable, so the definition is auditable.
Rebuilt sessions are only as complete as the events beneath them. First-party, server-side collection such as Robin Signals reduces the gaps caused by ad blockers and client-side data loss, which makes re-sessionisation in BigQuery more reliable.
In causal work the session is often the unit of observation. A badly placed boundary produces misattributed conversions and incorrect treatment assignment, and the estimate is biased before any model is fitted. A session definition built for the specific question and documented in dbt is part of the experimental design, not a reporting detail.
Viktor Kvant
Senior Web Analyst specialising in data ownership, advanced tracking implementations, and translating data into strategic business value.
Connect on LinkedIn