Run a custom GA4 report by property id
google-analytics.reportRun a traffic or behaviour report on your own Google Analytics property
- Prix
- freeAu prix catalogue
- Taux de réussite
- 100 %30 derniers jours · 15 619 appels
- Latence p50
- 545 msp95 2.3 s
- Dernière vérification
- 28 juil. 2026Vérifié et opérationnel
POSThttps://toolswitch.dev/v1/tools/google-analytics.reportBeta- Utilise le quota de la plateforme
- Réponse synchrone
- Lit des données publiques
Paramètres
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
| Paramètre | Type | Obligatoire | Description | Exemple |
|---|---|---|---|---|
| Paramètres de chemin | ||||
property_id | chaîne | Obligatoire | numeric GA4 property id (the digits only — the admin API returns it as 'properties/123456789') | 123456789 |
| Corps (JSON) | ||||
limit | entier | Facultatif | default 10000, max 250000 | 100 |
offset | entier | Facultatif | 0 | |
metrics | tableau | Facultatif | [{name: …}] — e.g. screenPageViews, sessions, activeUsers, conversions, engagementRate | [{"name":"screenPageViews"}] |
orderBys | tableau | Facultatif | e.g. [{"metric":{"metricName":"sessions"},"desc":true}] | |
dateRanges | tableau | Obligatoire | up to 4 ranges. Use 'yesterday' or 'NdaysAgo', not 'today' — today is a partial day and always reads low | [{"endDate":"yesterday","startDate":"28daysAgo"}] |
dimensions | tableau | Facultatif | [{name: …}] — e.g. pagePath, sessionSource, sessionDefaultChannelGroup, country, deviceCategory, date | [{"name":"pagePath"}] |
keepEmptyRows | booléen | Facultatif | ||
dimensionFilter | objet | Facultatif | e.g. {"filter":{"fieldName":"pagePath","stringFilter":{"matchType":"CONTAINS","value":"/blog/"}}} | |
- Paramètres de chemin
property_idchaîneObligatoirenumeric GA4 property id (the digits only — the admin API returns it as 'properties/123456789')
Exemple :
123456789- Corps (JSON)
limitentierFacultatifdefault 10000, max 250000
Exemple :
100offsetentierFacultatifExemple :
0metricstableauFacultatif[{name: …}] — e.g. screenPageViews, sessions, activeUsers, conversions, engagementRate
Exemple :
[{"name":"screenPageViews"}]orderBystableauFacultatife.g. [{"metric":{"metricName":"sessions"},"desc":true}]
dateRangestableauObligatoireup to 4 ranges. Use 'yesterday' or 'NdaysAgo', not 'today' — today is a partial day and always reads low
Exemple :
[{"endDate":"yesterday","startDate":"28daysAgo"}]dimensionstableauFacultatif[{name: …}] — e.g. pagePath, sessionSource, sessionDefaultChannelGroup, country, deviceCategory, date
Exemple :
[{"name":"pagePath"}]keepEmptyRowsbooléenFacultatifdimensionFilterobjetFacultatife.g. {"filter":{"fieldName":"pagePath","stringFilter":{"matchType":"CONTAINS","value":"/blog/"}}}
Exemples de code
Remplacez $TOOLSWITCH_KEY par la clé créée dans la 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());Cette API de passerelle est en version Beta ; son URL et son authentification peuvent changer. Les paramètres de l’exemple sont des données fictives. Les appels sont facturés à free, frais de service inclus.