Page Summary
-
The Google Analytics Realtime API provides customized reports of realtime event data for your property, showing events and usage from the last 30 minutes.
-
The HTTP request for this API is a POST request to
https://analyticsdata.googleapis.com/v1alpha/{property=properties/*}:runRealtimeReport, using a path parameter for the GA4 property identifier. -
The request body allows you to specify dimensions, metrics, filters, limits, metric aggregations, and ordering for the report.
-
The response body contains the report data, including dimension headers, metric headers, rows of data, and optional totals, maximums, minimums, and row count.
-
Access to the API requires one of the specified OAuth scopes:
https://www.googleapis.com/auth/analytics.readonlyorhttps://www.googleapis.com/auth/analytics.
The Google Analytics Realtime API returns a customized report of realtime event data for your property. These reports show events and usage from the last 30 minutes.
HTTP request
POST https://analyticsdata.googleapis.com/v1alpha/{property=properties/*}:runRealtimeReport
The URL uses gRPC Transcoding syntax.
Path parameters
| Parameters | |
|---|---|
property |
A Google Analytics GA4 property identifier whose events are tracked. Specified in the URL path and not the body. To learn more, see where to find your Property ID. Example: properties/1234 |
Request body
The request body contains data with the following structure:
| JSON representation | |
|---|---|
{ "dimensions": [ { object ( |
|
| Fields | |
|---|---|
dimensions[] |
The dimensions requested and displayed. |
metrics[] |
The metrics requested and displayed. |
limit |
The number of rows to return. If the |
dimensionFilter |
The filter clause of dimensions. Dimensions must be requested to be used in this filter. Metrics cannot be used in this filter. |
metricFilter |
The filter clause of metrics. Applied at post aggregation phase, similar to SQL having-clause. Metrics must be requested to be used in this filter. Dimensions cannot be used in this filter. |
metricAggregations[] |
Aggregation of metrics. Aggregated metric values will be shown in rows where the dimensionValues are set to "RESERVED_(MetricAggregation)". |
orderBys[] |
Specifies how rows are ordered in the response. |
returnPropertyQuota |
Toggles whether to return the current state of this Analytics Property's Realtime quota. Quota is returned in PropertyQuota. |
Response body
If successful, the response body contains data with the following structure:
The response realtime report table corresponding to a request.
| JSON representation | |
|---|---|
{ "dimensionHeaders": [ { object ( |
|
| Fields | |
|---|---|
dimensionHeaders[] |
Describes dimension columns. The number of DimensionHeaders and ordering of DimensionHeaders matches the dimensions present in rows. |
metricHeaders[] |
Describes metric columns. The number of MetricHeaders and ordering of MetricHeaders matches the metrics present in rows. |
rows[] |
Rows of dimension value combinations and metric values in the report. |
totals[] |
If requested, the totaled values of metrics. |
maximums[] |
If requested, the maximum values of metrics. |
minimums[] |
If requested, the minimum values of metrics. |
rowCount |
The total number of rows in the query result, regardless of the number of rows returned in the response. For example if a query returns 175 rows and includes limit = 50 in the API request, the response will contain rowCount = 175 but only 50 rows. |
propertyQuota |
This Analytics Property's Realtime quota state including this request. |
Authorization Scopes
Requires one of the following OAuth scopes:
https://www.googleapis.com/auth/analytics.readonlyhttps://www.googleapis.com/auth/analytics