Runs a Google Analytics 4 report for a property: any dimensions and metrics over date ranges, with filters, sorting and paging.
curl -X POST "https://api.primaryapi.com/v1/run/google-analytics.report" \
-H "Authorization: Bearer $PRIMARYAPI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"propertyId":"312345678","dimensions":["sessionDefaultChannelGroup"],"metrics":["sessions","engagementRate"],"orderBys":[{"metric":{"metricName":"sessions"},"desc":true}],"limit":2}'{
"output": {
"found": true,
"data": {
"rowCount": 6,
"nextCursor": "eyJvIjoyfQ",
"rows": [
{
"dimensions": { … },
"metrics": { … }
}, …
],
"dimensionHeaders": [
"sessionDefaultChannelGroup"
], …
}
},
"credits": 1
}Input and output
13 fields
312345678.["sessions","engagementRate"].["sessionDefaultChannelGroup"].[{"metric":{"metricName":"sessions"},"d….2.10 fields
Good to know
Runs as your connected Google account. Needs the Read Google Analytics capability.
Uses the GA4 Data API. dimension and metric API names come from google-analytics.metadata.
Each call spends the property’s own Data API quota (shown in propertyQuota). When it runs out Google answers with a rate limit until the quota refills.
With several date ranges each row also carries its date range (index or name).
The same key and credits work for every API.