Session Story Sign in
← Back to Developers

REST API

Access your Session Story analytics data programmatically. The same API that powers the dashboard is available for direct use.

Authentication

All API requests require a Bearer token. You can find your API key on any site's settings page in the dashboard.

Include it in the Authorization header:

Authorization: Bearer sk_your_api_key_here

All authenticated endpoints return 401 Unauthorized if the token is missing or invalid, and 403 Forbidden if the resource doesn't belong to your account.

Base URL

https://www.sessionstory.io/api

List sites

Returns all sites belonging to the authenticated user, including visitor/session/event counts and a 7-day sparkline.

GET /api/sites

Example response

[
  {
    "id": "abc123",
    "name": "My Site",
    "domain": "example.com",
    "tracking_id": "site_xxxxxxxxxxxxxxxx",
    "visitors_count": 1200,
    "sessions_count": 3400,
    "events_count": 15000,
    "sparkline": [12, 18, 25, 30, 22, 19, 28]
  }
]

Get site

GET /api/sites/{site_id}

Example response

{
  "id": "abc123",
  "name": "My Site",
  "domain": "example.com",
  "tracking_id": "site_xxxxxxxxxxxxxxxx",
  "visitors_count": 1200,
  "sessions_count": 3400,
  "events_count": 15000
}

Create site

POST /api/sites

Request body

{
  "name": "My New Site",
  "domain": "newsite.com"
}
FieldTypeDescription
namestringRequired. Display name for the site.
domainstringRequired. Domain of the site.

Dashboard overview

Returns the main analytics overview for a site — sessions over time, bounce rate, average session duration, referrers, top pages, top events, countries, and devices.

GET /api/sites/{site_id}/analytics/dashboard

Query parameters

ParamTypeDescription
fromdatetimeOptional. Start of date range (ISO 8601).
todatetimeOptional. End of date range. Defaults to now.

Response fields

FieldDescription
sessions_over_timeArray of {period, count} objects.
granularity"hour" or "day", based on date range.
total_sessionsTotal session count in the range.
bounce_ratePercentage of sessions with ≤ 1 pageview.
avg_session_durationAverage session duration in seconds.
referrersTop 10 traffic sources with counts.
top_pagesTop 10 pages by pageview count.
top_eventsTop 10 custom events (deduplicated per session).
countriesSessions by country code.
devicesSessions by device type (Phone, Tablet, Desktop).

Revenue

Returns revenue analytics if revenue tracking is configured for the site.

GET /api/sites/{site_id}/analytics/revenue

Query parameters

ParamTypeDescription
fromdatetimeOptional. Start of date range.
todatetimeOptional. End of date range.

Response fields

FieldDescription
configuredBoolean. False if revenue tracking is not set up.
summary{total_revenue, total_transactions, avg_order_value}
revenue_over_timeArray of {period, revenue, transactions}.
by_sourceRevenue breakdown by traffic source.
by_campaignRevenue breakdown by source and campaign.

Friction analysis

Analyzes visitor behavior quality by traffic source and campaign. Categorizes sessions into behavior buckets: bouncer, skimmer, hesitator, or engaged.

GET /api/sites/{site_id}/analytics/friction

Query parameters

ParamTypeDescription
fromdatetimeOptional. Start of date range.
todatetimeOptional. End of date range.

Response

Returns a sources array, each with key, total, buckets, bucket_pct, and nested campaigns array with the same structure.

Scroll depth

Returns scroll depth distribution (25%, 50%, 75%, 100%) per page.

GET /api/sites/{site_id}/analytics/scroll-depth

Query parameters

ParamTypeDescription
urlstringOptional. Filter to a specific page URL.
limitintegerOptional. Max pages to return (default 20, max 100).

Engagement funnel

Shows how many sessions reach each scroll depth milestone on a given page.

GET /api/sites/{site_id}/analytics/engagement-funnel

Query parameters

ParamTypeDescription
urlstringOptional. Filter to a specific page URL.

Reach

Shows what percentage of sessions from each source/campaign reached a specific page or triggered a specific event.

GET /api/sites/{site_id}/analytics/reach

Query parameters

ParamTypeDescription
metricstringRequired. "page" or "event".
valuestringRequired. The page path or event type to measure reach for.
fromdatetimeOptional. Start of date range.
todatetimeOptional. End of date range.

Custom event types

Lists all custom event types tracked on the site with their counts.

GET /api/sites/{site_id}/analytics/custom-event-types

Query parameters

ParamTypeDescription
fromdatetimeOptional. Start of date range.
todatetimeOptional. End of date range.

Custom event funnel

Builds a conversion funnel from a sequence of custom event types. Shows how many sessions progress through each step.

GET /api/sites/{site_id}/analytics/custom-event-funnel

Query parameters

ParamTypeDescription
steps[]arrayRequired. 2-10 event type names defining the funnel steps.
fromdatetimeOptional. Start of date range.
todatetimeOptional. End of date range.

Example request

GET /api/sites/{site_id}/analytics/custom-event-funnel?steps[]=signup_start&steps[]=signup_complete&steps[]=first_purchase

Event data keys

Returns the unique data property keys found in events of a given type. Useful for discovering what custom data is being tracked.

GET /api/sites/{site_id}/analytics/event-data-keys

Query parameters

ParamTypeDescription
typestringRequired. The event type to inspect.

List visitors

Returns paginated visitors for a site, ordered by most recently seen.

GET /api/sites/{site_id}/visitors

Query parameters

ParamTypeDescription
pageintegerOptional. Page number (50 visitors per page).

Visitor sessions

Returns all sessions for a specific visitor.

GET /api/visitors/{visitor_id}/sessions

Session events

Returns all events in a specific session, ordered chronologically.

GET /api/visitors/{visitor_id}/sessions/{session_id}/events