Data integration
GA4 to BigQuery: send Google Analytics 4 reports to BigQuery
Last updated Sunday, Aug 2, 2026
How it works
- 1
Create a service account and share GA4 access
OptimaFlo connects with a Google service account, not a personal login. Share your GA4 property with the service account email as a Viewer, the same way you would share a BigQuery dataset.
- 2
Configure the report: property, dimensions, and metrics
Set the numeric GA4 property ID, pick dimensions (like date or country), pick at least one metric (like sessions or eventCount), and a lookback window (90 days by default).
- 3
Validate against the live metadata catalog
OptimaFlo calls the GA4 metadata endpoint and checks every configured dimension and metric name against it, so a typo fails at setup instead of silently ingesting nothing for that column.
- 4
Land in Raw (Iceberg)
The report runs and pages past GA4's 250,000-row response cap automatically, landing rows as an Iceberg table in your own cloud.
- 5
Model Clean and Ready, then export to BigQuery
The AI data team builds Clean and Ready layers on the report data, then the Gold table exports to your BigQuery project and dataset.
GA4 to BigQuery through OptimaFlo means: a service account with Viewer access on your GA4 property, a report definition (dimensions, metrics, lookback window), and a BigQuery dataset to receive the modeled output. Service account setup and property sharing take about 20 to 30 minutes the first time; report configuration is a few minutes after that.
How the connector actually talks to GA4
This is the Google Analytics Data API (analyticsdata.googleapis.com), called directly with httpx and a minted bearer token, not the google-analytics-data SDK and not GA4's native BigQuery export linking. It hits two endpoints: a metadata endpoint that returns the full catalog of dimensions and metrics available on your property, and runReport, which returns report rows for the dimensions, metrics, and date range you configured. Because GA4 caps a single runReport response at 250,000 rows, the connector pages through limit/offset automatically until a page comes back short, or until an explicit row cap (used for previews) is reached.
Auth is service-account only, on purpose
v1 of this connector requires service_account_json, a JSON dict, JSON string, or file path, and validation fails before a connector object is even created if it is missing. There is deliberately no Application Default Credentials fallback: if there were, OptimaFlo's own platform identity could stand in for a customer's GA4 access, which is not what you want when the whole point of BYOC is that your data and your access stay yours. You share the GA4 property with the service account's email address, the same flow as sharing a BigQuery dataset with a service account.
Schema validation against the live catalog
Every configured dimension and metric name is checked against your property's actual metadata catalog before the first row is fetched. A dimension you typed wrong, or a metric that does not exist on this property, raises a clear error naming the bad field, rather than silently ingesting a report with a missing column. GA4's own metric types (TYPE_INTEGER, TYPE_FLOAT, and others) map to a coarse integer/float/string schema; unmapped types stay string, which matches the API's own wire format (runReport returns every value as a string regardless of its declared type).
Getting to BigQuery
Once the report data has gone through Clean and Ready modeling, the Gold table exports to your BigQuery project and dataset, in append, overwrite, or upsert mode, the same destination path every other source uses.
What is not supported
No real-time or streaming GA4 data (this is the standard reporting API, with its usual data-processing latency), no BigQuery-export-linked ingestion path, and no ADC fallback if you would rather skip service account key management. The 90-day default lookback is configurable up to about ten years, but every run re-requests the full configured window; there is no incremental "only fetch new dates" behavior built in yet.
Frequently asked questions
Set up by an AI data team, not a config file
Connect this source and see it land in your own cloud.
Now in early beta. One flat plan, no per-query tax. Runs in your cloud. Your data never leaves.