The GA4 Data API
The Google Analytics Data API (Data API v1) returns GA4 report data programmatically — you specify dimensions, metrics, date ranges, and filters and receive rows. It powers custom dashboards and pipelines, but it shares the UI's quotas, sampling for some requests, and cardinality limits, which must be designed around.
What this means
The Data API (developers.google.com analytics Data API v1) accepts a runReport-style request listing dimensions, metrics, date ranges, and filter expressions, and returns the matching rows. It is how programmatic reporting, custom dashboards, and scheduled extracts read GA4 without the UI.
Quotas, cardinality, and sampling
The API enforces token-based quotas per property and per project; heavy or frequent queries can exhaust them and return quota errors. It applies the same cardinality grouping into (other) for high-cardinality dimensions, and some requests can be sampled. Design queries to request only needed dimensions, batch sensibly, and check the response metadata for sampling and quota consumption rather than assuming every call is unlimited and exact.
- runReport-style dimensions, metrics, filters
- Token-based quotas per property and project
- Cardinality and possible sampling apply
How it appears in analytics and logs
An API response is a report query result subject to quotas and limits. A 429 or quota error means you've hit token limits; unexpectedly grouped rows can be cardinality (other) just as in the UI.
Diagnostic use case
Pull GA4 report data into a warehouse, a custom dashboard, or a scheduled job by querying dimensions and metrics directly instead of exporting from the UI.
What WebmasterID can help detect
WebmasterID exposes first-party analytics programmatically too, so you can build pipelines on owned data without third-party cookies.
Common mistakes
- Ignoring quota consumption until requests start failing.
- Assuming API results are never sampled or grouped.
- Hardcoding credentials instead of keeping them secret.
Privacy and accuracy notes
The Data API returns aggregated report data and enforces thresholds; it is not an export of raw user-level events. Keep credentials secret and request only needed fields.
Related pages
- Custom and calculated metrics in reports
GA4 lets you define custom metrics (registered from numeric event parameters) and calculated metrics (formulas combining existing metrics, like revenue per user). They extend reporting beyond the built-ins, but calculated metrics inherit the scope and null-handling of their inputs, which is where formulas go wrong.
- Report sharing and permissions
Access to reports is governed by roles: GA4 grants property-level roles (Viewer, Analyst, Editor, Administrator) plus data restrictions for cost/revenue, while Looker Studio shares per report with view/edit and link options. The pitfall is data-source credentials — a shared report can expose data the viewer couldn't query themselves.
- API export limits
Programmatic exports through the GA4 Data API are bounded: a single response returns up to a fixed number of rows, and each query is limited in how many dimensions and metrics it may combine. Pulls that ignore these limits truncate without obviously failing, producing partial datasets that look complete. This page explains the row and field caps and the pagination that avoids silent truncation.
- MCP analytics
Query first-party analytics programmatically.
Sources and verification notes
Last reviewed 2026-06-24. Facts are checked against primary/official sources where available; uncertain specifics are marked “Data not yet verified” rather than guessed.