Query Sessions
The session-level counterpart to Query Events, grouping visits rather than individual events. Adds session-only metrics (pageViews, bounceRate, avgSessionSec) that cannot be derived from the event stream. Use this for traffic and engagement reporting, and Query Events for anything keyed on a specific action. Page path is not a session dimension — a visit spans many pages. Top pages is Query Events with groupBy: "pathname" and action: "Page View".
Authorization
Authorization In: header
Path Parameters
ID of the project to query.
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Dimension to aggregate by. One row comes back per distinct value. Use date or hour for a time series. botOperator is who runs an automated client and is empty for people, so pair it with traffic; an automated client that does not name itself comes back as an empty string. Page path is not a session dimension — a visit spans many pages. Top pages is Query Events with groupBy: "pathname" and action: "Page View".
Optional second dimension, giving one row per groupBy × subGroupBy pair.
Metrics to compute for each row. At least one is required.
Start of the window as a YYYY-MM-DD date, inclusive. Interpreted in timeZone (the signed-in user's local zone on the dashboard, otherwise UTC).
End of the window as a YYYY-MM-DD date, inclusive. Interpreted in timeZone (the signed-in user's local zone on the dashboard, otherwise UTC).
IANA timezone for calendar dates and chart buckets. The dashboard sends the signed-in user's local zone. Defaults to UTC.
Only include sessions from this country name.
Only include sessions from this device type, e.g. mobile.
Only include sessions from this browser, e.g. Chrome.
Only include sessions from this referring domain.
Whose traffic to count: human (people, the default), ai (AI assistants and AI crawlers that loaded the page) or crawler (every other automated client).
Only include sessions from this channel: ai, search, social, direct, or referral. ai is people sent by an AI assistant, not automated crawlers.
Only include sessions attributed to this AI assistant, by referrer or by utm_source when the referrer is missing.
Only include sessions tagged with this utm_source.
Only include sessions tagged with this utm_medium.
Only include sessions tagged with this utm_campaign.
Only include sessions tagged with this utm_term.
Only include sessions tagged with this utm_content.
Only include sessions attributed to this ad ID.
Column to sort by: either groupBy or one of the requested metrics.
Sort direction. Ignored unless orderBy is set.
Number of rows to skip before collecting results.
Maximum number of rows to return.
Response Body
application/json
application/json
application/json
application/json
application/json
curl -X POST "https://example.com/projects/string/analytics/query-sessions" \ -H "Content-Type: application/json" \ -d '{ "groupBy": "projectId", "metrics": [ "users" ] }'{ "meta": [ { "name": "string", "type": "string" } ], "rows": 0, "statistics": { "bytes_read": 0, "elapsed": 0, "rows_read": 0 }, "usage": { "cost": 0, "duration": 0, "metricCount": 0 }, "data": [ { "avgSessionSec": 0, "bounceRate": 0, "events": 0, "groupBy": "string", "pageViews": 0, "sessions": 0, "subGroupBy": "string", "users": 0 } ]}User Events
Returns one user's event history, newest first: the activity timeline for a single person. Events fired before they were identified are stitched in by anonymous ID, so the timeline reaches back past the `identify()` call. Social-proof popup events are excluded. Page through it with `cursor`, which is a row offset: pass the number of rows already received to get the next batch.
AI Traffic
AI traffic for the dashboard: visits from AI assistants over time, a human comparison, landing pages, events by channel, and automated agents and crawlers. Existing session and event reports stay human-only; this is the view that includes automated traffic, kept separate from people.