Skip to main content
TroopyDocs
Open Troopy
Troopy

API reference / Analytics

Get the retention of visitors

Who comes back. Each cohort is the visitors whose first visit fell in a week (or a month), the newest last. returned[0] is the cohort, and returned[n] is how many of them viewed a page n weeks (or months) later. A site with no cookies gives a new id to each visitor each day, so its cohorts stay empty (cookieless).

get/api/v1/analytics/retention

Authorization

HeaderAuthorization: Bearer <API key>
Or the headerX-API-Key: <API key>
API keyMake one in Troopy under Settings > API keys. It acts as you, in its workspace.

Other ways to call it

CLItroopy analytics retention
MCP tooltroopy_get_analytics_retention
Rate limit60 calls in 60 seconds, for each key

Query parameters

intervalenum<string>

weekmonth

Default "week"

cohortsinteger

How many weeks or months, the current one last

Default 8 · At least 2 · At most 12

Response

200 · application/json
data*object
4 properties
interval*enum<string>

weekmonth

timezone*string
cookieless*boolean
cohorts*array<object>
3 properties
start*string

ISO 8601 date and time

visitors*integer
returned*array<integer>

Errors

400 invalid_inputFix the field named in detail. Each operation's schema is in /api/v1/openapi.json.
401 unauthorizedSend an API key as `Authorization: Bearer tr_live_...`. Create one in Troopy under Settings.
403 forbiddenThe key lacks a scope this operation needs, or its owner lacks the role. detail says which; create a key with the scope, or ask an organization owner or admin.
429 rate_limitedWait the number of seconds in Retry-After, then retry.