Docs·Web analytics
/api/v1/event/analytics/web-analytics/onlineGet who is online now
Who is on the site right now: every person whose session had activity in the last 5 minutes, with their place, device, source and current page, plus counts by source, country and device. This is the data behind the Realtime page and the Online count. It takes no date range and no filter.
Activity means a page view, an event or the tracking script's keep-alive ping, so a visitor who switched tabs a minute ago still counts. An identified person is one entry even when they are active on two tabs or two devices, or signed out and back in (each sign-out starts a new visitor id). The entry shows their most recently active session. At most 1,000 people are returned, longest session first, and online counts the ones returned.
Keys: an account key. Getting started explains both kinds.
Parameters
| Prop | In | Type | Notes |
|---|---|---|---|
contactListId | query | string | The id of the audience (the tracked site) to read, a UUID: anything else returns a 400. You must be a member of the workspace the audience belongs to, or the call returns a 401. An id that matches no audience is not an error: the call returns no data. |
Response
| Prop | Type | Notes |
|---|---|---|
online | number | How many people are in visitors. |
visitors | OnlineVisitor[] | One entry per online person, longest session first: id, contactId, name, country, city, latitude, longitude, browser, os, device, referrer, currentUrl, sessionSeconds, totalVisits and isCustomer. |
referrers | OnlineCount[] | Online visitors per source, most first, as { name, count }. Visitors with no source count as Direct. |
countries | OnlineCount[] | Online visitors per two-letter country code, most first, as { name, count }. Unknown countries are left out. |
devices | OnlineCount[] | Online visitors per device type (Desktop, Mobile, Tablet), most first, as { name, count }. |
Each item in visitors
| Prop | Type | Notes |
|---|---|---|
id | string | The visitor id of the person's most recently active session. |
country | string | Two-letter country code, '' when unknown. |
city | string | City, '' when unknown. |
name | string | In visitors, the first email address of an identified visitor, or null. In the three counts, the value being counted. |
contactId | string | The person id of an identified visitor, '' for an anonymous one. |
isCustomer | boolean | true when the person has ever paid (net revenue above 0). |
os | string | Operating system, such as Windows. |
device | string | Desktop, Mobile or Tablet. |
browser | string | Browser, such as Chrome. |
referrer | string | Source of the current session, such as Google, or Direct. |
currentUrl | string | Path of the last page the visitor viewed, such as /pricing. |
sessionSeconds | number | Seconds from the start of the current session to its latest activity. |
totalVisits | number | The person's sessions over all time, on every browser. |
latitude | number | Approximate latitude, null when unknown. |
longitude | number | Approximate longitude, null when unknown. |
Request
curl 'https://app.spreelytics.com/api/v1/event/analytics/web-analytics/online?contactListId=…' \
-H 'Authorization: Bearer YOUR_API_KEY'
const url = new URL('https://app.spreelytics.com/api/v1/event/analytics/web-analytics/online');
url.searchParams.set('contactListId', '…');
const res = await fetch(url, {
headers: { Authorization: 'Bearer YOUR_API_KEY' },
});
const data = await res.json();
import requests
res = requests.get(
"https://app.spreelytics.com/api/v1/event/analytics/web-analytics/online",
headers={"Authorization": "Bearer YOUR_API_KEY"},
params={"contactListId": "…"},
)
data = res.json()
Response
{
"online": 0,
"visitors": [
{
"id": "string",
"country": "string",
"city": "string",
"name": "string",
"contactId": "string",
"isCustomer": true,
"os": "string",
"device": "string",
"browser": "string",
"referrer": "string",
"currentUrl": "string",
"sessionSeconds": 0,
"totalVisits": 0,
"latitude": 0,
"longitude": 0
}
],
"referrers": [
{
"name": "string",
"count": 0
}
],
"countries": [
{
"name": "string",
"count": 0
}
],
"devices": [
{
"name": "string",
"count": 0
}
]
}