Run a custom GA4 report by property id
google-analytics.reportRun a traffic or behaviour report on your own Google Analytics property
- Price
- freeAt list price
- Success rate
- 100%Last 30 days · 15,619 calls
- Latency p50
- 545 msp95 2.3 s
- Last verified
- Jul 28, 2026Verified working
POSThttps://toolswitch.dev/v1/tools/google-analytics.reportBeta- Uses platform quota
- Synchronous response
- Reads public data
Parameters
request shape previously live-verified via the registry entry's examples. An incompatible dimension/metric pair fails the whole call — check google.analytics.metadata for what combines. Sampling and thresholding are reported back in the response metadata, not as an error
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| Path parameters | ||||
property_id | string | Required | numeric GA4 property id (the digits only — the admin API returns it as 'properties/123456789') | 123456789 |
| Request body (JSON) | ||||
limit | integer | Optional | default 10000, max 250000 | 100 |
offset | integer | Optional | 0 | |
metrics | array | Optional | [{name: …}] — e.g. screenPageViews, sessions, activeUsers, conversions, engagementRate | [{"name":"screenPageViews"}] |
orderBys | array | Optional | e.g. [{"metric":{"metricName":"sessions"},"desc":true}] | |
dateRanges | array | Required | up to 4 ranges. Use 'yesterday' or 'NdaysAgo', not 'today' — today is a partial day and always reads low | [{"endDate":"yesterday","startDate":"28daysAgo"}] |
dimensions | array | Optional | [{name: …}] — e.g. pagePath, sessionSource, sessionDefaultChannelGroup, country, deviceCategory, date | [{"name":"pagePath"}] |
keepEmptyRows | boolean | Optional | ||
dimensionFilter | object | Optional | e.g. {"filter":{"fieldName":"pagePath","stringFilter":{"matchType":"CONTAINS","value":"/blog/"}}} | |
- Path parameters
property_idstringRequirednumeric GA4 property id (the digits only — the admin API returns it as 'properties/123456789')
Example:
123456789- Request body (JSON)
limitintegerOptionaldefault 10000, max 250000
Example:
100offsetintegerOptionalExample:
0metricsarrayOptional[{name: …}] — e.g. screenPageViews, sessions, activeUsers, conversions, engagementRate
Example:
[{"name":"screenPageViews"}]orderBysarrayOptionale.g. [{"metric":{"metricName":"sessions"},"desc":true}]
dateRangesarrayRequiredup to 4 ranges. Use 'yesterday' or 'NdaysAgo', not 'today' — today is a partial day and always reads low
Example:
[{"endDate":"yesterday","startDate":"28daysAgo"}]dimensionsarrayOptional[{name: …}] — e.g. pagePath, sessionSource, sessionDefaultChannelGroup, country, deviceCategory, date
Example:
[{"name":"pagePath"}]keepEmptyRowsbooleanOptionaldimensionFilterobjectOptionale.g. {"filter":{"fieldName":"pagePath","stringFilter":{"matchType":"CONTAINS","value":"/blog/"}}}
Code samples
Replace $TOOLSWITCH_KEY with the key you created in the console.
curl -X POST 'https://toolswitch.dev/v1/tools/google-analytics.report' \
-H "X-Toolswitch-Key: $TOOLSWITCH_KEY" \
-H "Content-Type: application/json" \
--data-raw '{"limit":3,"metrics":[{"name":"sessions"}],"dateRanges":[{"endDate":"yesterday","startDate":"28daysAgo"}],"dimensions":[{"name":"sessionDefaultChannelGroup"}]}'import os
import json
import requests
response = requests.request(
"POST",
"https://toolswitch.dev/v1/tools/google-analytics.report",
headers={"X-Toolswitch-Key": os.environ["TOOLSWITCH_KEY"]},
json=json.loads("{\"limit\":3,\"metrics\":[{\"name\":\"sessions\"}],\"dateRanges\":[{\"endDate\":\"yesterday\",\"startDate\":\"28daysAgo\"}],\"dimensions\":[{\"name\":\"sessionDefaultChannelGroup\"}]}"),
)
response.raise_for_status()
print(response.text)const response = await fetch("https://toolswitch.dev/v1/tools/google-analytics.report", {
method: "POST",
headers: {
"X-Toolswitch-Key": process.env.TOOLSWITCH_KEY ?? "",
"Content-Type": "application/json",
},
body: JSON.stringify(JSON.parse("{\"limit\":3,\"metrics\":[{\"name\":\"sessions\"}],\"dateRanges\":[{\"endDate\":\"yesterday\",\"startDate\":\"28daysAgo\"}],\"dimensions\":[{\"name\":\"sessionDefaultChannelGroup\"}]}")),
});
if (!response.ok) throw new Error(`Request failed: ${response.status}`);
console.log(await response.text());This gateway API is in beta; its URL and authentication may change. The example parameters are sample data. Calls are billed at free, including the service fee.