Run a custom GA4 report by property id
google-analytics.reportRun a traffic or behaviour report on your own Google Analytics property
- Precio
- freeA precio de catálogo
- Tasa de éxito
- 100 %Últimos 30 días · 15.619 llamadas
- Latencia p50
- 545 msp95 2.3 s
- Última verificación
- 28 jul 2026Verificado y operativo
POSThttps://toolswitch.dev/v1/tools/google-analytics.reportBeta- Usa la cuota de la plataforma
- Respuesta síncrona
- Lee datos públicos
Parámetros
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
| Parámetro | Tipo | Obligatorio | Descripción | Ejemplo |
|---|---|---|---|---|
| Parámetros de ruta | ||||
property_id | cadena | Obligatorio | numeric GA4 property id (the digits only — the admin API returns it as 'properties/123456789') | 123456789 |
| Cuerpo (JSON) | ||||
limit | entero | Opcional | default 10000, max 250000 | 100 |
offset | entero | Opcional | 0 | |
metrics | matriz | Opcional | [{name: …}] — e.g. screenPageViews, sessions, activeUsers, conversions, engagementRate | [{"name":"screenPageViews"}] |
orderBys | matriz | Opcional | e.g. [{"metric":{"metricName":"sessions"},"desc":true}] | |
dateRanges | matriz | Obligatorio | up to 4 ranges. Use 'yesterday' or 'NdaysAgo', not 'today' — today is a partial day and always reads low | [{"endDate":"yesterday","startDate":"28daysAgo"}] |
dimensions | matriz | Opcional | [{name: …}] — e.g. pagePath, sessionSource, sessionDefaultChannelGroup, country, deviceCategory, date | [{"name":"pagePath"}] |
keepEmptyRows | booleano | Opcional | ||
dimensionFilter | objeto | Opcional | e.g. {"filter":{"fieldName":"pagePath","stringFilter":{"matchType":"CONTAINS","value":"/blog/"}}} | |
- Parámetros de ruta
property_idcadenaObligatorionumeric GA4 property id (the digits only — the admin API returns it as 'properties/123456789')
Ejemplo:
123456789- Cuerpo (JSON)
limitenteroOpcionaldefault 10000, max 250000
Ejemplo:
100offsetenteroOpcionalEjemplo:
0metricsmatrizOpcional[{name: …}] — e.g. screenPageViews, sessions, activeUsers, conversions, engagementRate
Ejemplo:
[{"name":"screenPageViews"}]orderBysmatrizOpcionale.g. [{"metric":{"metricName":"sessions"},"desc":true}]
dateRangesmatrizObligatorioup to 4 ranges. Use 'yesterday' or 'NdaysAgo', not 'today' — today is a partial day and always reads low
Ejemplo:
[{"endDate":"yesterday","startDate":"28daysAgo"}]dimensionsmatrizOpcional[{name: …}] — e.g. pagePath, sessionSource, sessionDefaultChannelGroup, country, deviceCategory, date
Ejemplo:
[{"name":"pagePath"}]keepEmptyRowsbooleanoOpcionaldimensionFilterobjetoOpcionale.g. {"filter":{"fieldName":"pagePath","stringFilter":{"matchType":"CONTAINS","value":"/blog/"}}}
Ejemplos de código
Sustituye $TOOLSWITCH_KEY por la clave que creaste en la consola.
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());La API de la pasarela está en Beta; su URL y autenticación pueden cambiar. Los parámetros del ejemplo son datos de muestra. Las llamadas se facturan a free, incluida la tarifa de servicio.