GA4 realtime active users by page, source, country
google-analytics.realtimeSee who is on your site right now (active users by page, source and country)
- Preço
- freePelo preço de tabela
- Taxa de sucesso
- 100%Últimos 30 dias · 1.086 chamadas
- Latência p50
- 368 msp95 572 ms
- Última verificação
- 28 de jul. de 2026Verificado e funcionando
POSThttps://toolswitch.dev/v1/tools/google-analytics.realtimeBeta- Usa a cota da plataforma
- Resposta síncrona
- Lê dados públicos
Parâmetros
covers the last 30 minutes only, and takes NO dateRanges — passing one is an error. Reusing a standard-report dimension name here is the usual failure
| Parâmetro | Tipo | Obrigatório | Descrição | Exemplo |
|---|---|---|---|---|
| Parâmetros de caminho | ||||
property_id | string | Obrigatório | 123456789 | |
| Corpo (JSON) | ||||
limit | inteiro | Opcional | 20 | |
metrics | matriz | Obrigatório | activeUsers, screenPageViews, conversions | [{"name":"activeUsers"}] |
dimensions | matriz | Opcional | realtime has its OWN smaller dimension set — unifiedScreenName, country, deviceCategory, audienceName; pagePath is not among them | [{"name":"unifiedScreenName"}] |
minuteRanges | matriz | Opcional | windows within the last 30 minutes, e.g. [{"startMinutesAgo":29,"endMinutesAgo":0}] | |
- Parâmetros de caminho
property_idstringObrigatórioExemplo:
123456789- Corpo (JSON)
limitinteiroOpcionalExemplo:
20metricsmatrizObrigatórioactiveUsers, screenPageViews, conversions
Exemplo:
[{"name":"activeUsers"}]dimensionsmatrizOpcionalrealtime has its OWN smaller dimension set — unifiedScreenName, country, deviceCategory, audienceName; pagePath is not among them
Exemplo:
[{"name":"unifiedScreenName"}]minuteRangesmatrizOpcionalwindows within the last 30 minutes, e.g. [{"startMinutesAgo":29,"endMinutesAgo":0}]
Exemplos de código
Substitua $TOOLSWITCH_KEY pela chave criada no console.
curl -X POST 'https://toolswitch.dev/v1/tools/google-analytics.realtime' \
-H "X-Toolswitch-Key: $TOOLSWITCH_KEY" \
-H "Content-Type: application/json" \
--data-raw '{"limit":3,"metrics":[{"name":"activeUsers"}],"dimensions":[{"name":"country"}]}'import os
import json
import requests
response = requests.request(
"POST",
"https://toolswitch.dev/v1/tools/google-analytics.realtime",
headers={"X-Toolswitch-Key": os.environ["TOOLSWITCH_KEY"]},
json=json.loads("{\"limit\":3,\"metrics\":[{\"name\":\"activeUsers\"}],\"dimensions\":[{\"name\":\"country\"}]}"),
)
response.raise_for_status()
print(response.text)const response = await fetch("https://toolswitch.dev/v1/tools/google-analytics.realtime", {
method: "POST",
headers: {
"X-Toolswitch-Key": process.env.TOOLSWITCH_KEY ?? "",
"Content-Type": "application/json",
},
body: JSON.stringify(JSON.parse("{\"limit\":3,\"metrics\":[{\"name\":\"activeUsers\"}],\"dimensions\":[{\"name\":\"country\"}]}")),
});
if (!response.ok) throw new Error(`Request failed: ${response.status}`);
console.log(await response.text());Esta API de gateway está em Beta; a URL e a autenticação podem mudar. Os parâmetros do exemplo são dados de amostra. As chamadas são cobradas a free, incluindo a taxa de serviço.