Sending Website Sessions via the Tracking API
A reference for the /sessions endpoint, which records site-wide traffic by device type.
2 min read
The /sessions endpoint records a single visit to your website, by device type. It measures site-wide traffic, and it is what the dashboard’s session totals and the "traffic under test" figure are calculated from.
It has no experiment or variant dimension at all, and it does not contribute to experiment results. If you are reporting a server side experiment, the endpoint you want is /visitors.
The request
POST https://tracking.pertento.ai/sessions?websiteId=<websiteId>&deviceType=Desktop
Both parameters go in the query string and both are required. There is no body and no authentication.
Parameters
- websiteId — the numeric id of the website the visit belongs to.
- deviceType — exactly one of
Desktop,MobileorTablet. The match is case-sensitive:desktopormobileis rejected, and the request is accepted and discarded rather than returning an error.
Any other value, or a missing parameter, means nothing is recorded.
When you need to send this
Most sites never call it. The Pertento script reports sessions automatically, so if the script is installed this is already happening.
Send it yourself when the script is not on the page and you still want site-wide traffic figures in Pertento — typically a server-rendered application reporting entirely from the back end. Without it, the dashboard has no denominator, and the share of traffic under test cannot be calculated.
One request per session
Each request counts as exactly one session. There is no batch form, no count parameter and no way to set the timestamp: every session is recorded at the moment the request arrives.
As with the other tracking endpoints, deduplication is entirely yours to manage. The browser runtime guards against double-counting with a per-session flag in session storage; the server has no equivalent. Send one request when a visit begins, not once per page view, or your session totals will read as page views instead.
Notes
- Session counts feed the dashboard tiles, not experiment significance.
- The website id is not validated. An id that does not correspond to a real website is accepted and the traffic is recorded against nothing you can see.
- The success response is returned before the write is attempted.
- Sessions are aggregated into hourly buckets, so figures appear with a short delay.