← Back to all posts GA4 to BigQuery customer intelligence pipeline showing data flow and analytics marts

GA4 + BigQuery: Customer-Intelligence Pipeline Patterns

Jun 2026 · Data Engineering

The Google Analytics 4 to BigQuery export is the most useful asset in a modern analytics stack, and one of the most underused. The reporting screens inside GA4 are built for aggregate dashboards. They're sampled, limited in cardinality and locked to a fixed set of dimensions. The BigQuery export gives you every raw event, unsampled, as data you own and can join to anything. Customer intelligence needs exactly that.

This is a hands-on guide to the patterns I use when I build customer-intelligence pipelines on GA4 + BigQuery for enterprise clients. It covers the parts of the export schema that trip people up, the staging models that turn raw events into something you can query, and the analytical marts the pipeline exists to produce: sessionization, identity stitching, RFM, lifetime value and cohorts. No client data appears here. The patterns are general and the SQL is illustrative.

Quick answer: Turn on the native GA4 BigQuery export, then build three layers on top of the raw events_* tables: a staging layer that flattens nested event parameters and rebuilds sessions, an identity layer that stitches user_pseudo_id to a stable user_id, and a marts layer that produces per-customer RFM, LTV, and cohort tables. Schedule it with dbt or scheduled queries and you have customer intelligence the GA4 UI can't give you.

Why GA4 + BigQuery for Customer Intelligence

GA4 was rebuilt around an event model. Every interaction is an event with parameters, instead of the session-and-hit model of Universal Analytics. That event model is awkward in the reporting UI but ideal in a warehouse. Three things make the BigQuery export the right foundation:

GA4 Events BigQuery Export raw · unsampled Customer Intelligence CRM · orders · product
GA4 exports every event to BigQuery unsampled. Joining that export to CRM, order and product tables turns raw events into customer intelligence.

The export itself is free for standard properties, including both the daily batch table and the streaming intraday table. Once the data lands, you only pay normal BigQuery storage and query costs, and partition pruning keeps those low if you model carefully.

The Pipeline in Four Layers

A layered design holds up best over time. Each layer has one job and feeds the next. Don't write one giant query against the raw export. It becomes impossible to maintain the first time the schema surprises you.

1. Raw / source

The untouched GA4 export: events_YYYYMMDD daily tables plus events_intraday_*. Never edited. This is your replayable source of truth.

2. Staging

Flatten event_params and user_properties, cast timestamps, rebuild sessions. One clean, typed row-per-event model the rest of the pipeline can trust.

3. Identity

Resolve devices to people. Map every user_pseudo_id to a stable customer key, stitching in user_id wherever a login event provides one.

4. Marts

The analytical outputs: sessions, funnels, RFM segments, lifetime value and cohort retention. All of them are keyed on the resolved customer and ready for BI and activation.

GA4 Export Schema: The Parts That Matter

The export lands in a dataset named analytics_<property_id>, with one partitioned table per day (events_YYYYMMDD) and a streaming table (events_intraday_YYYYMMDD) when streaming export is enabled. Each row is a single event. The fields that drive every downstream model:

Field Type What it is
event_name STRING The event: page_view, session_start, purchase, and your custom events.
event_timestamp INT64 Event time in microseconds since the Unix epoch. Divide by 1e6 before casting to a timestamp.
event_params RECORD, REPEATED Key/value array. The value sits in one of string_value, int_value, float_value, double_value. Holds ga_session_id, page_location, and more.
user_pseudo_id STRING Device/client identifier from the GA client_id cookie. Always present; resets on cookie clear or device switch.
user_id STRING The stable identifier you set on login. Present only when your site/app assigns it. The anchor for identity stitching.
user_properties RECORD, REPEATED Sticky user-scoped attributes (plan tier, lifecycle stage). Same nested key/value shape as event_params.
items RECORD, REPEATED Ecommerce line items on purchase/cart events: item id, name, price, quantity. The source of monetary value.
traffic_source / collected_traffic_source RECORD Acquisition attribution: source, medium, campaign. First-touch vs. event-level depending on the field.

Two facts cause the most confusion: timestamps are in microseconds, and there is no session table. GA4 doesn't store sessions as rows, so you rebuild them from events. The staging layer below handles both.

event_params repeated record string_value int_value float_value double_value
event_params is a repeated record. You UNNEST it and read the one typed value field (string, int, float, or double) that matches the parameter key.

Staging: Flatten Events and Rebuild Sessions

Because event_params is a repeated record, you pull a single parameter by unnesting it and selecting the typed value. You'll use this subquery pattern all over the pipeline:

SELECT
  event_date,
  TIMESTAMP_MICROS(event_timestamp)            AS event_ts,
  event_name,
  user_pseudo_id,
  user_id,
  -- pull the session id out of the nested params
  (SELECT value.int_value FROM UNNEST(event_params)
     WHERE key = 'ga_session_id')              AS ga_session_id,
  (SELECT value.string_value FROM UNNEST(event_params)
     WHERE key = 'page_location')              AS page_location,
  -- a globally-unique session key: device + session number
  CONCAT(
    user_pseudo_id, '.',
    CAST((SELECT value.int_value FROM UNNEST(event_params)
            WHERE key = 'ga_session_id') AS STRING)
  )                                            AS session_key
FROM `project.analytics_123456789.events_*`
WHERE _TABLE_SUFFIX BETWEEN '20260101' AND '20260131'

Two habits keep this layer solid. The first is about cost:

Always filter on _TABLE_SUFFIX (the date sharded into the table name) so BigQuery only reads the days you need. Querying events_* without a suffix filter scans your entire history, and it's the number-one cause of surprise bills.

The second is the session key: user_pseudo_id concatenated with ga_session_id. GA4 itself uses it internally to count sessions, and it's globally unique. Group by it to rebuild sessions. The first and last event timestamps give you session start, end and duration. The count of page_view events gives you depth. A purchase event marks a converting session. That one sessions model feeds funnels, engagement metrics and attribution downstream.

page_view page_view purchase session_key = pseudo_id + session_id Session start · end · depth · converted
GA4 has no session table. Group events that share a device and ga_session_id into a session_key, then work out start, end, depth, and whether the session converted.

Identity Resolution: Devices to People

This layer is what separates real customer intelligence from page-view reporting. user_pseudo_id answers "which browser?" Customer intelligence needs "which person?" The mapping is rarely one-to-one. One customer shows up as many pseudo-ids across devices and cookie resets, and one shared device can have several people on it.

To stitch them, take every user_pseudo_id that ever appears with a known user_id (because the user logged in during at least one event), and copy that user_id to all of that device's events. Build a crosswalk table:

-- one row per device, resolved to a stable customer key where known
SELECT
  user_pseudo_id,
  -- the most recent non-null user_id seen on this device
  ARRAY_AGG(user_id IGNORE NULLS ORDER BY event_timestamp DESC LIMIT 1)[SAFE_OFFSET(0)]
    AS resolved_user_id
FROM `project.analytics_123456789.events_*`
WHERE _TABLE_SUFFIX BETWEEN '20260101' AND '20260131'
GROUP BY user_pseudo_id

Downstream, the customer key is COALESCE(resolved_user_id, user_pseudo_id). Use the real person when you know it, and fall back to the device when you don't. Every per-customer metric keys on that. Tell stakeholders up front that stitching is an estimate. Anonymous behavior before login only attaches to a person after the fact, and cross-device coverage is only as good as your login rate. Name those limits in the deliverable so nobody assumes the resolution is perfect.

pseudo_id: dev-123 no login seen pseudo_id: dev-456 user_id: alan42 (login) crosswalk: propagate known user_id to every pseudo_id customer_key = COALESCE(user_id, pseudo_id)
A login event on one device is enough to resolve every pseudo_id that device has ever used to a single, stable customer_key.

The Marts: What Customer Intelligence Produces

With clean sessions and resolved customers, the analytical marts are simple to write. I build these same four on almost every client project.

RFM Segments

Start here

Recency, Frequency and Monetary value per customer, scored into quintiles. It turns raw purchase events into named segments (champions, loyal, at-risk, lapsed), and it's the fastest way to get from data to action.

Lifetime Value

Revenue lens

Total purchase value per resolved customer, with an optional forward projection. It ties acquisition spend and retention priorities to real revenue instead of proxies.

Cohort Retention

Trend lens

Group customers by first-seen week or month, then track return/purchase rate over subsequent periods. Shows whether product and lifecycle changes move retention.

Funnel / Conversion

Behavior lens

Ordered event sequences (view → add-to-cart → checkout → purchase) measured per session and per customer. Shows which step people drop off at.

RFM is the best place to start, because it's cheap to compute and you can act on it right away. From the resolved purchase events:

WITH purchases AS (
  SELECT
    COALESCE(resolved_user_id, user_pseudo_id)   AS customer_key,
    TIMESTAMP_MICROS(event_timestamp)            AS purchase_ts,
    (SELECT value.double_value FROM UNNEST(event_params)
       WHERE key = 'value')                      AS purchase_value
  FROM staged_events
  WHERE event_name = 'purchase'
)
SELECT
  customer_key,
  DATE_DIFF(CURRENT_DATE(), DATE(MAX(purchase_ts)), DAY)  AS recency_days,
  COUNT(*)                                                AS frequency,
  SUM(purchase_value)                                     AS monetary
FROM purchases
GROUP BY customer_key

Wrap each of recency, frequency, and monetary in NTILE(5) OVER (...) to score quintiles, then map the score triples to segment names. That one table drives lifecycle email, paid-audience exclusions and win-back campaigns, which is the activation side of customer intelligence.

purchase events RFM quintile scores champions · at-risk · lapsed lifecycle email paid-audience exclusion win-back campaign
Use the RFM segments to trigger lifecycle emails, set paid-audience exclusions and run win-back campaigns.

Scheduling and Orchestration

The export refreshes daily (intraday if streaming is on), so the pipeline should refresh on the same schedule. Here are the common approaches:

Approach Best for Trade-off
dbt Teams wanting version-controlled models, tests, lineage, and documentation More setup; needs a runner (dbt Cloud, Cloud Run, or scheduled CI)
BigQuery scheduled queries Small pipelines, fast start, no extra tooling No tests or lineage; logic lives in the console, harder to review
Incremental tables Large histories where full refresh is wasteful Cheapest at scale; only process yesterday's partition each run

For anything beyond a couple of models, dbt with incremental materializations is the pattern that scales. Each run processes only the newest daily partition, the models are tested, and the lineage from raw export to RFM mart is documented and reviewable. That pays off the first time a stakeholder questions a number, because "here's the model and the test that guards it" is a much better answer than "the dashboard says so."

Common Dead Ends to Avoid

Frequently Asked Questions

Is the GA4 BigQuery export free?
The GA4 to BigQuery export itself is free for standard properties, including the daily batch export and the streaming (intraday) export. You pay normal BigQuery storage and query costs on the data once it lands. Daily export volume is capped on standard properties; Analytics 360 raises the limit and adds a freshness SLA.
What is the difference between user_id and user_pseudo_id in GA4 BigQuery?
user_pseudo_id is the device or client identifier from the GA client_id cookie. It's always present, but it resets when a user clears cookies or switches devices. user_id is the stable identifier you set when a user logs in. Customer intelligence keys on user_id when it exists and falls back to user_pseudo_id otherwise. Stitching the two together is the core of identity resolution.
How do you get a single event parameter value out of the GA4 BigQuery export?
event_params is a repeated RECORD, so you UNNEST it and pull the typed value. For example, to read the session id: (SELECT value.int_value FROM UNNEST(event_params) WHERE key = 'ga_session_id'). The value lives in one of string_value, int_value, float_value, or double_value depending on the parameter, so you select the matching field.
How do you define a session in the GA4 BigQuery export?
A session is the combination of user_pseudo_id and the ga_session_id event parameter. Concatenate those two and you get a globally unique session key you can group by. GA4 has no session table, so you rebuild sessions from events. That's why a sessionization staging model is the first thing most pipelines build.
What is RFM segmentation and how does it map to GA4 data?
RFM scores each customer on Recency (days since last purchase), Frequency (number of purchases), and Monetary value (total revenue). In GA4 BigQuery you derive all three from purchase events: recency from the latest event_timestamp, frequency from the purchase event count, and monetary from the summed purchase value. Scoring each dimension into quintiles produces actionable segments like champions, at-risk, and lapsed.
Why use BigQuery instead of the GA4 reporting interface for customer intelligence?
The GA4 interface is built for aggregate reporting, so it applies sampling, cardinality limits and a fixed set of dimensions. The BigQuery export gives you raw, unsampled, event-level data you can join to CRM, orders and product tables. Customer intelligence work like per-user LTV, identity stitching and custom cohorts needs that row-level access, and the reporting UI can't provide it.

Building a customer-intelligence stack?

I run a free community for people building real data and AI pipelines: warehouse modeling, analytics, and AI-augmented workflows. There's no course and no paywall. It's people who build and ship real work.

Join the free AI community →

Related reading: AI in Enterprise Data Work — What Actually Ships: the patterns that deliver value versus the ones that stall. AI as an Operations Layer: scheduled analysis and DataOps opportunity discovery. LLMs Explained: why private, first-party data is where enterprise AI gets interesting. For the hardware side of running AI locally, see Blendlogic Tech.

Get the build notes

My AI experiments: what worked, what didn’t, and how I set them up. Sent to your inbox.

No spam, unsubscribe anytime · Privacy

More in AI & Building →