---
title: "Counting GA4 sessions in BigQuery without getting it wrong"
description: "The GA4 export has no sessions table. Three SQL definitions give 118,380, 116,549, and 117,127 sessions on one month of data. Here is which to keep."
canonical: https://www.rtbanalytics.fr/en/blog/ga4-bigquery-export/ga4-sessions-bigquery
date: 2026-11-15T11:30:00+01:00
author: "Boris Parov"
lang: en
---

# Counting GA4 sessions in BigQuery without getting it wrong

The Google Analytics 4 (GA4) BigQuery export has no sessions table: a session is whatever your SQL defines. On Google's public sample, January 2021 gives three counts: 118,380, 116,549, and 117,127 sessions. This article runs each method, explains the gaps, and picks one, as our [guide to the GA4 BigQuery export](https://www.rtbanalytics.fr/en/blog/ga4-bigquery-export) recommends.

**Key takeaways**

- The export stores events, not sessions, so every session count in BigQuery is a definition you choose and must keep.
- Counting distinct `user_pseudo_id` and `ga_session_id` pairs gives 118,380 sessions in January 2021 on the public sample.
- Counting `session_start` events gives 116,549, because 1,866 sessions of January 2021 have no `session_start` event in the export.
- Re-sessionizing events with a 30-minute gap gives 117,127 sessions, and 238 sessions of January 2021 cross midnight.

## Why is there no sessions table in the GA4 export?

The GA4 export writes one row per event, so a session is only a key shared by rows. GA4 never writes a row that stands for a session. It writes events, and stamps each one with two session parameters inside `event_params`.

A **GA4 session** is a group of events from one `user_pseudo_id` that share one `ga_session_id`, closed after 30 minutes of inactivity by default.

`ga_session_id` is the timestamp, in seconds, of the moment the session started. Google's documentation says so in plain words. `ga_session_number` counts the sessions that user has started so far. Neither is a column: you read them from `event_params` with a subquery on `UNNEST`.

The key is present on every row of the public sample. All 1,210,147 event rows of January 2021 carry a `ga_session_id`, as the pillar guide measured. That is what makes a session recoverable from events at all.

The consequence is simple and often missed. Since there is no table, there is no official count either. The GA4 interface does not count rows. By Google's own account, it estimates the number of unique session IDs. Your SQL counts them exactly, under a definition you write. The three methods that follow are the three definitions in common use.

## Method 1: `user_pseudo_id` + `ga_session_id`

Counting distinct pairs of `user_pseudo_id` and `ga_session_id` counts sessions the way GA4 identifies them. The pair matters. A `ga_session_id` is a start time in seconds. Two users who start a session in the same second share it. Counting `ga_session_id` alone would merge their sessions.

The query below builds one row per pair, then counts. It also returns the controls used in the next two sections, so one scan answers all of them.

```sql
WITH ev AS (
  SELECT
    user_pseudo_id,
    event_name,
    event_date,
    (SELECT value.int_value FROM UNNEST(event_params) WHERE key = 'ga_session_id') AS ga_session_id
  FROM `bigquery-public-data.ga4_obfuscated_sample_ecommerce.events_*`
  WHERE _TABLE_SUFFIX BETWEEN '20210101' AND '20210131'
),
sessions AS (
  SELECT
    user_pseudo_id,
    ga_session_id,
    COUNTIF(event_name = 'session_start') AS session_starts,
    COUNT(DISTINCT event_date) AS event_dates
  FROM ev
  GROUP BY user_pseudo_id, ga_session_id
)
SELECT
  COUNT(*) AS sessions_by_id,
  COUNTIF(ga_session_id IS NULL) AS sessions_without_id,
  SUM(session_starts) AS session_start_events,
  COUNTIF(session_starts = 0) AS sessions_without_start,
  COUNTIF(session_starts > 1) AS sessions_with_several_starts,
  COUNTIF(event_dates > 1) AS sessions_over_two_dates
FROM sessions
```

| Measure                                           | January 2021 |
| ------------------------------------------------- | ------------ |
| Sessions (`user_pseudo_id` + `ga_session_id`)     | 118,380      |
| Sessions without a `ga_session_id`                | 0            |
| `session_start` events                            | 116,549      |
| Sessions with no `session_start` event            | 1,866        |
| Sessions with more than one `session_start` event | 33           |
| Sessions spread over two `event_date` values      | 238          |

Computed on 2026-10-15 on the public sample `bigquery-public-data.ga4_obfuscated_sample_ecommerce` (Google Merchandise Store, 2020-11-01 to 2021-01-31, obfuscated data).

The result is 118,380 sessions, the same figure as the pillar guide. No row lacks the identifier, so no session falls out of the count. This is the definition to start from: it reads GA4's own key and adds no rule of yours.

## Method 2: counting `session_start` events, and its holes

Counting `session_start` events gives 116,549 sessions in January 2021, which is 1,831 fewer than Method 1. The method looks natural, since GA4 fires one event when a session begins. It breaks on two kinds of sessions.

A **`session_start` event** is an event that GA4 collects automatically when a session begins, at the moment it generates the session's `ga_session_id`, and that carries the attribution data of the start.

The first hole is the larger one. 1,866 sessions of January 2021 have events but no `session_start` in the export. Counting events misses every one of them. The second hole runs the other way: 33 sessions carry more than one `session_start`. Counting events counts them twice or more.

The two effects partly cancel out, which hides the problem. The arithmetic is exact: 118,380 sessions, minus 1,866 without a start, plus 35 extra start events, gives 116,549.

The holes matter beyond the total. Google documents that `session_start` carries attribution information: the gclid, UTM parameters, and referrer. A model that reads the session's source only from `session_start` leaves 1,866 sessions without a source. The choice of field per question is covered in which traffic-source field to read for each question.

Use `session_start` for what it carries, not as a counter. Count sessions with the pair from Method 1, then join the start attributes where they exist.

## Method 3: re-sessionizing at 30 minutes

Re-sessionizing rebuilds sessions from timestamps alone and gives 117,127 sessions in January 2021. It ignores `ga_session_id` entirely.

**Re-sessionization** is a SQL method that rebuilds sessions from event timestamps alone, opening a new session for a user whenever the gap since that user's previous event exceeds a set timeout, here 30 minutes.

The query sorts each user's events by `event_timestamp` and reads the previous one with `LAG`. A new session opens on a user's first event, or after a gap over 30 minutes. The timestamp is in microseconds, hence the multiplier.

```sql
WITH ev AS (
  SELECT
    user_pseudo_id,
    event_date,
    event_timestamp,
    LAG(event_timestamp) OVER (PARTITION BY user_pseudo_id ORDER BY event_timestamp) AS previous_timestamp,
    LAG(event_date) OVER (PARTITION BY user_pseudo_id ORDER BY event_timestamp) AS previous_date
  FROM `bigquery-public-data.ga4_obfuscated_sample_ecommerce.events_*`
  WHERE _TABLE_SUFFIX BETWEEN '20210101' AND '20210131'
)
SELECT
  COUNTIF(previous_timestamp IS NULL
    OR event_timestamp - previous_timestamp > 30 * 60 * 1000000) AS sessions_30_min,
  COUNTIF(previous_timestamp IS NULL
    OR event_timestamp - previous_timestamp > 30 * 60 * 1000000
    OR event_date != previous_date) AS sessions_30_min_cut_at_midnight
FROM ev
```

| Re-sessionization rule                     | Sessions, January 2021 |
| ------------------------------------------ | ---------------------- |
| New session after 30 minutes of inactivity | 117,127                |
| Same rule, plus a new session at midnight  | 117,369                |

Computed on 2026-10-15 on the public sample `bigquery-public-data.ga4_obfuscated_sample_ecommerce` (Google Merchandise Store, 2020-11-01 to 2021-01-31, obfuscated data).

The method has one real strength: it works on any event log, with or without a session key. It also has a cost. The 30 minutes are your rule, not the property's. GA4 lets an administrator change the session timeout, and Google advises keeping the default. A property with a different timeout needs the same value in the query. The second row shows what a midnight cut adds: 242 sessions. That cut is the old rule, not the GA4 one.

## How do time zones and midnight change a GA4 session count?

GA4 does not restart a session at midnight, so one session can span two daily tables. Google states it in its comparison of GA4 with the previous version. Sessions aren't restarted at midnight or on new campaign parameters. Two controls follow from it.

### Sessions that cross midnight

238 sessions of January 2021 carry events on two `event_date` values. Two errors come from them. The first is adding daily counts: the sum of daily sessions is 238 higher than the monthly count. The second is a session that started the day before your first table. Its `session_start` sits in a table you did not read. The query below reads one extra day, December 31, to measure that edge.

```sql
WITH ev AS (
  SELECT
    user_pseudo_id,
    event_date,
    event_name,
    (SELECT value.int_value FROM UNNEST(event_params) WHERE key = 'ga_session_id') AS ga_session_id
  FROM `bigquery-public-data.ga4_obfuscated_sample_ecommerce.events_*`
  WHERE _TABLE_SUFFIX BETWEEN '20201231' AND '20210131'
),
sessions AS (
  SELECT
    user_pseudo_id,
    ga_session_id,
    COUNT(DISTINCT IF(event_date >= '20210101', event_date, NULL)) AS january_dates,
    COUNTIF(event_name = 'session_start' AND event_date >= '20210101') AS january_starts,
    COUNTIF(event_name = 'session_start' AND event_date = '20201231') AS december_31_starts
  FROM ev
  GROUP BY user_pseudo_id, ga_session_id
)
SELECT
  COUNTIF(january_dates > 0) AS january_sessions,
  SUM(january_dates) AS sum_of_daily_sessions,
  COUNTIF(january_dates > 1) AS sessions_over_two_dates,
  COUNTIF(january_dates > 0 AND january_starts = 0) AS sessions_without_start,
  COUNTIF(january_dates > 0 AND january_starts = 0 AND december_31_starts > 0) AS started_on_december_31
FROM sessions
```

| Measure                                     | January 2021 |
| ------------------------------------------- | ------------ |
| Sessions (monthly distinct count)           | 118,380      |
| Sum of daily session counts                 | 118,618      |
| Sessions spread over two dates              | 238          |
| Sessions with no `session_start` in January | 1,866        |
| Of which started on December 31             | 3            |

Computed on 2026-10-15 on the public sample `bigquery-public-data.ga4_obfuscated_sample_ecommerce` (Google Merchandise Store, 2020-11-01 to 2021-01-31, obfuscated data).

Only 3 of the 1,866 missing starts sit in the previous day's table. The other 1,863 have no `session_start` in any table read. The rule for a sessions table: assign each session to the date of its first event, once.

### `event_date` and `event_timestamp` do not share a time zone

`event_date` is written in the property's time zone, while `event_timestamp` is in UTC. Google's export schema documents both. A model that derives the date from `event_timestamp` without conversion moves events across midnight.

```sql
SELECT
  COUNT(*) AS event_rows,
  COUNTIF(PARSE_DATE('%Y%m%d', event_date) != DATE(TIMESTAMP_MICROS(event_timestamp))) AS rows_utc_date_differs,
  COUNTIF(PARSE_DATE('%Y%m%d', event_date) != DATE(TIMESTAMP_MICROS(event_timestamp), 'America/Los_Angeles')) AS rows_los_angeles_date_differs,
  MIN(TIME(TIMESTAMP_MICROS(event_timestamp), 'America/Los_Angeles')) AS first_local_time,
  MAX(TIME(TIMESTAMP_MICROS(event_timestamp), 'America/Los_Angeles')) AS last_local_time
FROM `bigquery-public-data.ga4_obfuscated_sample_ecommerce.events_*`
WHERE _TABLE_SUFFIX BETWEEN '20210101' AND '20210131'
```

| Measure                                                   | January 2021 |
| --------------------------------------------------------- | ------------ |
| Event rows                                                | 1,210,147    |
| Rows whose `event_date` differs from the UTC date         | 0            |
| Rows whose `event_date` differs from the Los Angeles date | 399,254      |

Computed on 2026-10-15 on the public sample `bigquery-public-data.ga4_obfuscated_sample_ecommerce` (Google Merchandise Store, 2020-11-01 to 2021-01-31, obfuscated data).

On the sample, `event_date` matches the UTC date on every row. A property set to Los Angeles time would differ on 399,254 rows of 1,210,147. Run this control on your own property before you trust any daily count. The same date question shapes user counts, covered in [why BigQuery and the GA4 interface never show the same number of users](https://www.rtbanalytics.fr/en/blog/ga4-bigquery-export/ga4-users-bigquery-discrepancy).

## Which of the three GA4 session counts should you keep?

Keep Method 1, the `user_pseudo_id` and `ga_session_id` pair, and write it in one place. It reads GA4's own key and adds no rule of yours. Its count is also the closest to the interface's.

| Method                             | Sessions, January 2021 | Use it for                                         |
| ---------------------------------- | ---------------------- | -------------------------------------------------- |
| `user_pseudo_id` + `ga_session_id` | 118,380                | The session count of every report                  |
| `session_start` events             | 116,549                | Start attributes, joined to Method 1               |
| Re-sessionization at 30 minutes    | 117,127                | Logs without a session key, cross-tool comparisons |

Computed on 2026-10-15 on the public sample `bigquery-public-data.ga4_obfuscated_sample_ecommerce` (Google Merchandise Store, 2020-11-01 to 2021-01-31, obfuscated data).

The gap between Methods 1 and 3 is not noise: it is two opposite effects, measured below.

```sql
WITH ev AS (
  SELECT
    user_pseudo_id,
    event_timestamp,
    (SELECT value.int_value FROM UNNEST(event_params) WHERE key = 'ga_session_id') AS ga_session_id,
    IF(LAG(event_timestamp) OVER w IS NULL OR event_timestamp - LAG(event_timestamp) OVER w > 30 * 60 * 1000000, 1, 0) AS new_session
  FROM `bigquery-public-data.ga4_obfuscated_sample_ecommerce.events_*`
  WHERE _TABLE_SUFFIX BETWEEN '20210101' AND '20210131'
  WINDOW w AS (PARTITION BY user_pseudo_id ORDER BY event_timestamp)
),
numbered AS (
  SELECT *, SUM(new_session) OVER (PARTITION BY user_pseudo_id ORDER BY event_timestamp ROWS UNBOUNDED PRECEDING) AS session_30
  FROM ev
),
by30 AS (
  SELECT user_pseudo_id, session_30, COUNT(DISTINCT ga_session_id) AS ids FROM numbered GROUP BY 1, 2
),
byid AS (
  SELECT user_pseudo_id, ga_session_id, COUNT(DISTINCT session_30) AS parts FROM numbered GROUP BY 1, 2
)
SELECT
  (SELECT COUNT(*) FROM by30) AS sessions_30,
  (SELECT COUNTIF(ids > 1) FROM by30) AS sessions_30_with_several_ids,
  (SELECT SUM(ids - 1) FROM by30) AS extra_ids_merged,
  (SELECT COUNT(*) FROM byid) AS sessions_by_id,
  (SELECT COUNTIF(parts > 1) FROM byid) AS id_sessions_split,
  (SELECT SUM(parts - 1) FROM byid) AS extra_parts
```

| Reconciliation                                                | January 2021 |
| ------------------------------------------------------------- | ------------ |
| Re-sessionized sessions holding more than one `ga_session_id` | 1,344        |
| Identifiers merged into another re-sessionized session        | 1,364        |
| Identifier sessions split by a gap over 30 minutes            | 109          |
| Extra parts created by those splits                           | 111          |

Computed on 2026-10-15 on the public sample `bigquery-public-data.ga4_obfuscated_sample_ecommerce` (Google Merchandise Store, 2020-11-01 to 2021-01-31, obfuscated data).

The arithmetic closes: 118,380, minus 1,364 merged identifiers, plus 111 extra parts, gives 117,127. GA4 sometimes opened a new identifier within 30 minutes, and sometimes kept one across a longer pause. The export does not say why. Once the definition is fixed, the measure on top of it must follow, as [the DAX measures for GA4 sessions and users](https://www.rtbanalytics.fr/en/blog/ga4-power-bi/dax-measures-ga4) describe.

> **In Lightstack · Available**
>
> Lightstack, by RTB Strategic Analytics (Montpellier, France), recomputes consultancy-grade GA4 analyses every day from the raw BigQuery export and delivers them in Power BI. Its `Sessions` measure is exact, defined once in the semantic model, and shared by every page. A filter on Spain or on mobile never changes the definition. See [Shared measures on the Platform page](https://www.rtbanalytics.fr/en/platform#model).

## FAQ

### Why don't my BigQuery sessions match the GA4 interface?

GA4 reports estimate the number of unique session IDs, while BigQuery counts them exactly. Google documents that estimate in its comparison of GA4 and the previous version. Consent refusals, data thresholds, and modeled data also act on the interface only. Expect a small, stable gap rather than an equal number. A gap that moves from one week to the next points to a tagging change.

### Does the GA4 export contain a session duration?

No, the GA4 export has no session duration column, because it has no session row. You compute duration from the events of each session. Take the first and last `event_timestamp` of each `user_pseudo_id` and `ga_session_id` pair, then subtract. The values are in microseconds. A session with a single event has a duration of zero under this rule.

### Does a new campaign start a new session in GA4?

No, a GA4 session does not restart when new campaign parameters arrive. Google states that sessions aren't restarted at midnight or on new campaign parameters. The previous version of Google Analytics did both. A re-sessionization query that cuts on a source change rebuilds the old behavior, not the GA4 one.

### Which session definition should a Power BI model use?

A Power BI model should count sessions with the `user_pseudo_id` and `ga_session_id` pair. Compute it upstream, in a sessions table. The model then holds one row or one key per session. Every page reads the same measure. Re-defining sessions inside a report, page by page, is how two pages end up disagreeing.

Keep one definition and make it the only one your reports use. The rest of [GA4 BigQuery export: the complete guide to raw event data](https://www.rtbanalytics.fr/en/blog/ga4-bigquery-export) shows where the other counts come from. Want new analyses like this one as they ship? [Get new analyses as they ship](https://www.rtbanalytics.fr/en/blog/ga4-bigquery-export/ga4-sessions-bigquery#footer-newsletter-email).

## Sources

- [BigQuery Export schema](https://support.google.com/analytics/answer/7029846) - Google, consulted 2026-10-15
- [About Analytics sessions](https://support.google.com/analytics/answer/9191807) - Google, consulted 2026-10-15
- [Comparing metrics: Google Analytics vs. Universal Analytics](https://support.google.com/analytics/answer/11986666) - Google, consulted 2026-10-15
- [Navigation functions (LAG)](https://docs.cloud.google.com/bigquery/docs/reference/standard-sql/navigation_functions) - Google Cloud, consulted 2026-10-15
