Analytics

Run a Google Analytics (GA4) report

Changed on

Runs a report on a connected GA4 property through Google's Data API (runReport).

Pick any GA4 dimensions and metrics; filters and ordering use Google's own shapes.

Caching and quota

Identical requests on the same property are cached for 10 minutes.

Google meters each property by quota tokens. When it is used up the request returns 429 until Google refills it (hourly quotas within the hour, daily ones at midnight Pacific time).

post/v1/analytics/googleanalytics/report

Request

  • Base URL
    https://zernio.com/api
  • URL
    https://zernio.com/api/v1/analytics/googleanalytics/report
  • Auth
    HTTP bearer

Request body

accountIdstring required

Zernio account ID of the Google Analytics connection (platform googleanalytics).

dimensionsstring[]

GA4 dimension API names, e.g. date, sessionSource, pagePath. List them with GET /v1/analytics/googleanalytics/metadata.

metricsstring[] required

GA4 metric API names, e.g. sessions, activeUsers, keyEvents, totalRevenue.

dimensionFilterobject

A Google FilterExpression on dimensions, in Google's own shape.

metricFilterobject

A Google FilterExpression on metrics, in Google's own shape.

orderBysobject[]

Google OrderBy objects, e.g. { "metric": { "metricName": "sessions" }, "desc": true }.

limitinteger

Rows to return. Defaults to Google's default (10000).

offsetinteger

Row offset for paging through a report larger than limit.

keepEmptyRowsboolean
currencyCodestring

ISO 4217 code for currency metrics. Defaults to the property currency.

Example request

{
  "dimensions": [
    "date",
    "sessionDefaultChannelGroup"
  ],
  "metrics": [
    "sessions",
    "activeUsers"
  ],
  "dateRanges": [
    {
      "startDate": "30daysAgo",
      "endDate": "today"
    }
  ]
}

Response

Report rows from Google

accountIdstring

Zernio account ID of the Google Analytics connection.

propertyIdstring

Numeric GA4 property ID.

rowCountinteger

Total rows matching the request, across all pages.

metadataobject

Google report metadata (currency, time zone, sampling and thresholding flags).

propertyQuotaobject

Google quota left on this property after the request (tokens per day and per hour, concurrent requests). Cached responses carry the quota from when they were fetched.

Changes