Setup guide · Google Analytics 4

Google Analytics 4 in Dataki, through the BigQuery export

Dataki does not call the Google Analytics API. It reads the export Google writes into BigQuery for free: every event with every parameter, unsampled, one table per day. You link the property once, connect the dataset, and ask.

  1. Google Analytics 4
  2. BigQuery export
  3. Dataki
Setup
About 10 minutes, then up to 24 hours before the first day of data arrives.
Cost
The daily export is free. BigQuery bills storage and queries beyond its free tier: 10 GiB of storage and 1 TiB of queries a month.
History
From the day you link. Nothing before it is exported, so link now even if you connect Dataki later.
You need
Editor on the GA4 property, and Owner on a Google Cloud project with the BigQuery API enabled.

01Before you start

  • A GA4 property where you are Editor or above.
  • A Google Cloud project where you are Owner. A new, empty project works; enable the BigQuery API in it.
  • Billing on that project if you want the streaming export, or history older than 60 days.

02Set it up

4 steps, about 10 minutes

  1. 01

    Link the property to BigQuery

    In Google Analytics, open Admin, then Product linksBigQuery links, and choose Link. Pick the Cloud project and a data location. The location cannot be changed without unlinking and starting again, so pick the region the rest of your data lives in.

  2. 02

    Choose what to export

    Turn on Daily. It writes one table per day, events_YYYYMMDD, holding the previous day's complete data, usually by the afternoon in the property's time zone. Submit, and Google creates a dataset named analytics_ followed by your property ID, e.g. analytics_123456789.

    • Streaming adds events_intraday_YYYYMMDD, updated within minutes. It costs about $0.05 per GB and does not run in the BigQuery sandbox. Dataki reads it when it is there.
    • Standard properties can send up to 1 million events a day through the daily export. A property that keeps going over has its daily export paused, so exclude noisy events or streams if you are close.
    • The user tables, pseudonymous_users_* and users_*, are optional. Most questions only need the events.
  3. 03

    Wait for the first table

    Data starts flowing within 24 hours of linking. Each daily table can keep changing for up to three days as late events arrive, so yesterday's numbers may still move a little.

  4. 04

    Connect the dataset in Dataki

    Open app.dataki.ai/connect and, under Linked Google Cloud Projects, choose Link New Google Project. Sign in with a Google account that can manage IAM in the project holding the data, and pick that project. Dataki creates a service account named Dataki in it with two roles, BigQuery Data Viewer and BigQuery Job User: it can read tables and run queries.

    The project's datasets then appear among your sources. Pick analytics_…. Each dataset is one source in Dataki, and the free plan includes one.

    Dataki shows the model the daily tables as one table, events_*, with its full date range, and lists every nested field of event_params and items. That is what lets a question about a page, a campaign or a purchase reach the right parameter.

03Ask it

Your first questions

Three first questions, each with a query that answers it. Dataki shows its own SQL next to every answer, so you can compare.

How many people and sessions did we have each week over the last three months?

A session is a ga_session_id within a user. This follows GA4's own definition, but the GA4 interface estimates its counts, so expect small differences.

BigQuery · analytics_123456789
SELECT
  DATE_TRUNC(PARSE_DATE('%Y%m%d', event_date), WEEK) AS week,
  COUNT(DISTINCT user_pseudo_id) AS users,
  COUNT(DISTINCT CONCAT(user_pseudo_id, '-',
    CAST((SELECT value.int_value FROM UNNEST(event_params) WHERE key = 'ga_session_id') AS STRING))) AS sessions
FROM `your-project.analytics_123456789.events_*`
WHERE _TABLE_SUFFIX BETWEEN FORMAT_DATE('%Y%m%d', DATE_SUB(CURRENT_DATE(), INTERVAL 12 WEEK))
                        AND FORMAT_DATE('%Y%m%d', CURRENT_DATE())
GROUP BY week
ORDER BY week

Which pages got the most views this month?

BigQuery · analytics_123456789
SELECT
  (SELECT value.string_value FROM UNNEST(event_params) WHERE key = 'page_location') AS page,
  COUNT(*) AS views
FROM `your-project.analytics_123456789.events_*`
WHERE event_name = 'page_view'
  AND _TABLE_SUFFIX >= FORMAT_DATE('%Y%m%d', DATE_TRUNC(CURRENT_DATE(), MONTH))
GROUP BY page
ORDER BY views DESC
LIMIT 20

Which sources first brought in the people who buy, and what did they spend?

traffic_source is where a user was first acquired. Newer exports also carry session_traffic_source_last_click, the session's own last-click source: ask for it by name when that is what you mean.

BigQuery · analytics_123456789
SELECT
  traffic_source.source,
  traffic_source.medium,
  COUNT(*) AS purchases,
  ROUND(SUM(ecommerce.purchase_revenue), 2) AS revenue
FROM `your-project.analytics_123456789.events_*`
WHERE event_name = 'purchase'
  AND _TABLE_SUFFIX >= FORMAT_DATE('%Y%m%d', DATE_SUB(CURRENT_DATE(), INTERVAL 90 DAY))
GROUP BY 1, 2
ORDER BY revenue DESC

04Worth knowing

What you will run into

Numbers will not match the GA4 interface exactly
The interface estimates user counts and can apply thresholds and modelled data. The export holds the raw events. Differences of a few percent are normal, and the export is the one you can check.
The BigQuery sandbox is for trying, not keeping
A project without billing runs in the BigQuery sandbox. Tables there expire after 60 days, storage is capped at 10 GiB for the life of the project, and streaming exports are not available. Add billing before you depend on the history.
Queries are billed to your project
Dataki runs each query in the project that holds the data, and Google bills that project for it. The first 1 TiB of queries each month is free. A question that names a period lets the query read only those days, which is what keeps it small.
Your organization may block the key Dataki needs
Linking a project creates a key for the Dataki service account. Google Cloud organizations created on or after 3 May 2024 block key creation by default, through the iam.disableServiceAccountKeyCreation policy. If linking fails there, an organization admin can lift that policy for this one project. Projects outside an organization are not affected.

Free while we are in beta

Connect Google Analytics 4. Ask it something.

Once the data is where Dataki can read it, the first answer is a question away, and anything worth keeping becomes a dashboard with a link that stays live.

One data source
Free tier. Connect a second on any paid plan.
Read-only
Every query runs read-only. Dataki cannot change your data.
No card
There is nothing to cancel if you stop.