Saasco logoSaasco logo
Saasco logoSaasco logo

Introduction

OverviewGetting startedAgent setupWhat is Saasco?

SDK

Quick startTrackingIdentifyConfigurationWidgetsProperties

MCP

Quick startHow it worksAuthorizationTool reference
Skills for agents

REST API

Quick start
postQuery SessionspostAI Traffic
AnalyticsSessions

Query Sessions

View as MarkdownAgent setup

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".

POST
/projects/{projectId}/analytics/query-sessions

Authorization

Authorization
AuthorizationBearer <token>

In: header

Path Parameters

projectIdrequiredstring

ID of the project to query.

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

groupByrequiredstring

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".

Value in: "projectId" | "date" | "hour" | "referringDomain" | "channel" | "aiTool" | "botOperator" | "device" | "browser" | "location" | "utmSource" | "utmMedium" | "utmCampaign" | "utmTerm" | "utmContent" | "utmAdId"
subGroupBystring

Optional second dimension, giving one row per groupBy × subGroupBy pair.

Value in: "projectId" | "date" | "hour" | "referringDomain" | "channel" | "aiTool" | "botOperator" | "device" | "browser" | "location" | "utmSource" | "utmMedium" | "utmCampaign" | "utmTerm" | "utmContent" | "utmAdId"
metricsrequiredarray<string>

Metrics to compute for each row. At least one is required.

dateFromstring

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).

dateTostring

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).

timeZonestring

IANA timezone for calendar dates and chart buckets. The dashboard sends the signed-in user's local zone. Defaults to UTC.

locationstring

Only include sessions from this country name.

devicestring

Only include sessions from this device type, e.g. mobile.

browserstring

Only include sessions from this browser, e.g. Chrome.

referringDomainstring

Only include sessions from this referring domain.

trafficstring

Whose traffic to count: human (people, the default), ai (AI assistants and AI crawlers that loaded the page) or crawler (every other automated client).

Value in: "human" | "ai" | "crawler"
channelstring

Only include sessions from this channel: ai, search, social, direct, or referral. ai is people sent by an AI assistant, not automated crawlers.

Value in: "ai" | "search" | "social" | "direct" | "referral"
aiToolstring

Only include sessions attributed to this AI assistant, by referrer or by utm_source when the referrer is missing.

Value in: "chatgpt" | "claude" | "gemini" | "copilot" | "perplexity" | "grok" | "meta" | "deepseek" | "mistral"
utmSourcestring

Only include sessions tagged with this utm_source.

utmMediumstring

Only include sessions tagged with this utm_medium.

utmCampaignstring

Only include sessions tagged with this utm_campaign.

utmTermstring

Only include sessions tagged with this utm_term.

utmContentstring

Only include sessions tagged with this utm_content.

utmAdIdstring

Only include sessions attributed to this ad ID.

orderBystring

Column to sort by: either groupBy or one of the requested metrics.

orderDirstring

Sort direction. Ignored unless orderBy is set.

Value in: "ASC" | "DESC"
skipinteger

Number of rows to skip before collecting results.

limitinteger

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.