How to Connect GA4 to BigQuery: Step-by-Step Tutorial, Tables and Real Costs

7 min read

If you read our article on ecommerce attribution, you already know the problem: platforms erase your history. Universal Analytics deleted 18 years of data in July 2024, and Meta limits its API to 37 months. The way out is to have your own copy of the data, and for that GA4 offers a native, free export to BigQuery.

There is one detail that changes everything: connecting GA4 to BigQuery is not retroactive. The export starts saving data from the day you turn it on, not one day earlier. Every week that goes by without the connection is a week of history you lose forever. That’s why this tutorial starts with the setup and ends with what your boss will actually ask you: how much does it cost?

Why export GA4 to BigQuery

The GA4 interface shows you aggregated data, with sampling in complex reports and privacy thresholds that hide rows. The BigQuery export gives you something else: every raw event, one by one, with all its parameters.

With that raw data you can do what the interface no longer allows. Apply your own attribution models (linear, first click, time decay, the ones Google removed from GA4 in 2023), automatically cross-check orders against your backend, and build real-time dashboards. For a Cyber event, that means seeing hour by hour which channel is selling, instead of waiting 24-48 hours for GA4 to consolidate.

Prerequisites

You need three things. A Google Cloud Platform account with a project created (at console.cloud.google.com). A credit card linked to the project: it’s a GCP requirement, but as long as you stay within the free tier it generates no charges. And editor permissions on the GA4 property.

If you have never used GCP, the whole process takes about 15 minutes.

Tutorial: set up the export in 6 steps

  1. Create the project in GCP and verify that the BigQuery API is enabled (it is active by default in new projects).
  2. In GA4, go to Admin → Product links → BigQuery links and click “Link.”
  3. Select your GCP project and the region where the data will be stored. Choose carefully: the region can’t be changed later without migrating the entire dataset. For Chile, us (multi-region) or southamerica-west1 (Santiago) are the reasonable options.
  4. Choose the export frequency. Daily creates one table per day with the consolidated data. Streaming writes events continuously, with a delay of a few seconds. You can turn on both. A relevant fact for large stores: the daily export has a limit of 1 million events per day on standard properties; streaming has no limit. There is a third option called Fresh Daily, which delivers the daily table in 30-60 minutes, but it is exclusive to Analytics 360.
  5. Configure what to export. You can include user data (the pseudonymous_users_ and users_ tables) and exclude high-volume, low-analytical-value events, such as page_view or scroll, if you want to control the size of the dataset. For attribution it’s best to keep them; to start lean, exclude them and adjust later.
  6. Save and wait. The first table appears within the next 24 hours in your project, under a dataset called analytics_XXXXXXXX (the number is your property ID).

The tables you’ll find

The export creates up to four types of tables, and it’s worth understanding what each one does before querying.

events_YYYYMMDD: one table per day with all events consolidated. It is your source of truth for reports. Google may keep adjusting the data for up to 72 hours afterward, so the last two or three days may vary slightly.

events_intraday_YYYYMMDD: the table for the current day, populated by streaming. It’s useful for real-time monitoring, with one warning: fields such as traffic_source and user_ltv are not populated there. For attribution analysis, always use the daily tables.

pseudonymous_users_YYYYMMDD and users_YYYYMMDD: user profiles. The first is based on the device identifier (user_pseudo_id); the second on your own user_id, if you implemented it. They bring something the GA4 interface doesn’t expose in this much detail: audience membership and predictive metrics such as churn probability and projected revenue per user. With that you can, for example, export your high-value users to your CRM or as a remarketing audience.

The particular thing about the schema is that it is nested. Each row is an event, but its parameters live in event_params, an array of key/value pairs. That means that to extract any custom parameter you need SQL’s UNNEST function. It looks odd the first time and then becomes mechanical.

Three queries to get started

Replace your_project.analytics_XXXXXXXX with your actual project and dataset, and adjust the _TABLE_SUFFIX dates. If you want more examples after these, Google maintains an official library of basic queries on the export schema.

1. Sales and revenue by day. The basis of the reconciliation ritual against your backend that we describe in the attribution article:

sql

SELECT
  event_date,
  COUNT(DISTINCT ecommerce.transaction_id) AS orders,
  ROUND(SUM(ecommerce.purchase_revenue), 0) AS revenue
FROM `your_project.analytics_XXXXXXXX.events_*`
WHERE _TABLE_SUFFIX BETWEEN '20260601' AND '20260630'
  AND event_name = 'purchase'
GROUP BY event_date
ORDER BY event_date;

2. Purchases by source and medium. To see which channels are closing sales according to the raw data:

sql

SELECT
  collected_traffic_source.manual_source AS source,
  collected_traffic_source.manual_medium AS medium,
  COUNT(DISTINCT ecommerce.transaction_id) AS purchases,
  ROUND(SUM(ecommerce.purchase_revenue), 0) AS revenue
FROM `your_project.analytics_XXXXXXXX.events_*`
WHERE _TABLE_SUFFIX BETWEEN '20260601' AND '20260630'
  AND event_name = 'purchase'
GROUP BY 1, 2
ORDER BY revenue DESC;

3. Order IDs to cross-check against the backend, with an UNNEST example for extracting parameters:

sql

SELECT
  event_date,
  (SELECT value.string_value
   FROM UNNEST(event_params)
   WHERE key = 'transaction_id') AS order_id,
  ecommerce.purchase_revenue AS revenue
FROM `your_project.analytics_XXXXXXXX.events_*`
WHERE _TABLE_SUFFIX BETWEEN '20260601' AND '20260630'
  AND event_name = 'purchase'
ORDER BY event_date;

With this last list you do the order-by-order cross-check against your ecommerce platform. If an ID appears twice, you have an event firing in duplicate. And from here, the natural next step is your own attribution models: the full queries for first click, linear and time decay are in the appendices of our webinar presentation with Multivende. If you want to go deeper on how to rebuild the models Google removed, this article from mbuzz has the first-click and linear queries on the same export schema, along with a good explanation of how Google’s data-driven model works under the hood (it uses Shapley values, a game theory concept).

What it really costs

The short answer: for most Chilean stores, zero or close to zero.

BigQuery has a permanent free tier of 10 GB of storage and 1 TB of queries processed per month. Beyond that, on-demand prices are US$6.25 per TB queried and US$0.02 per GB of active storage per month (it drops by half for data not modified in more than 90 days). The daily export is free; streaming costs US$0.05 per GB inserted, equivalent to about 600,000 events per GB.

Grounded in real cases: a store with fewer than one million events a month generates on the order of 1-2 GB per month, and its typical queries process just a few GB. All within the free tier: US$0. A mid-sized store with streaming on and about 10 million events a month pays around US$1 for streaming and a few dollars for accumulated storage and queries. The order of magnitude is US$5 to US$20 a month, considerably less than any paid analytics tool.

The cost risk is in careless queries. BigQuery charges for data processed, and a SELECT * over the entire history scans every column of every table. Two habits prevent it: select only the columns you need and always filter by _TABLE_SUFFIX. The BigQuery editor shows you how much data the query will process before you run it; check it until it becomes a habit.

Common mistakes when connecting GA4 to BigQuery

Four we see often. Choosing the region without thinking and discovering later that migrating is a project in itself. Waiting for historical data that will never arrive, because the export starts at activation. Querying events_* without a date filter and processing the entire dataset on every query. And using the intraday tables for attribution analysis, where the traffic source fields come back empty.

Conclusion: turn it on today, even if you’re not using it yet

The connection takes 15 minutes, costs nothing for most stores and starts accumulating your data history from today. Even if you don’t have an analyst who writes SQL yet, the dataset will be there when you need it: to audit your measurement, to run your own attribution models or for the live dashboard at the next Cyber event.

Your business history stops belonging to the platforms and becomes yours. That is the real return on this setup.

Questions about the implementation, or want us to review your entire measurement setup? Let’s talk.


External sources cited

Questions about your measurement?

We review your entire setup, from GA4 to the dashboard.

Let’s talk

Questions about your measurement?

Let’s talk

Compartir

Contact