viakite
Dashboard

API/Reports/Retention cohorts

Retention cohorts

POST/v1/projects/{project}/analytics/retention

Groups people by the day, week or month in which they first did first_event (any page view or custom event by default) inside date_range, and counts how many of each cohort did return_event (the same default) in each period after, in the project's time zone. With count_by: users (the default) people are identified users (identify), with their visitors' anonymous events of the same day linked to them; users who did the first event before the range join no cohort. With count_by: visitors a visitor id lasts one day (no cookies), so visitors never come back in a later period. Filters apply to the first event.

Secret keyNeeds analytics.viewus.api.vk.viabio.me

Path parameters

projectstringrequired
The project's id (prj_…).

Body

granularitystring
The length of a cohort and of each period after it; week by default.
dayweekmonth
periodsinteger1–30
How many periods after the first to show; 14 days, 8 weeks or 6 months by default.
count_bystring
users (the default): identified people, across days and devices. visitors: a visitor id lasts one day, so no visitor comes back in a later period.
usersvisitors
first_eventobject
A page (exact, or with * for any part) or a custom event, with optional property conditions.
Show 3 fields
typestringrequired
pageevent
valuestringrequiredup to 255 chars
conditionsPropertyCondition[]up to 20 items
With type event, property tests the event must pass, all of them.
Show 3 fields
propertystringrequiredup to 255 chars
operatorstringrequired
isis_notcontainsstarts_with
valuestringrequiredup to 255 chars
return_eventobject
A page (exact, or with * for any part) or a custom event, with optional property conditions.
Show 3 fields
typestringrequired
pageevent
valuestringrequiredup to 255 chars
conditionsPropertyCondition[]up to 20 items
With type event, property tests the event must pass, all of them.
Show 3 fields
propertystringrequiredup to 255 chars
operatorstringrequired
isis_notcontainsstarts_with
valuestringrequiredup to 255 chars
filtersFilter[]
Who joins a cohort: the filters apply to the first event.
Show 4 fields
dimensionstring
A dimension's name; keyed ones take a key: props.plan.
operatorstring
isis_notcontainsnot_containsstarts_withregex
valuesstring[]1–20 items
orFilter[]
date_rangeobject
A preset, or from and to as dates (2026-11-01, whole days in the project's time zone, to included) or RFC 3339 times (to excluded). Empty means the last 30 days. A range starting before the first day the plan keeps (retention_days of F47: the last N days, today included, in the project's time zone) starts on that day instead: the answer's date_range shows where it starts, and F1, F2 and the public queries add a range_clamped warning. A range wholly before it is empty.
Show 3 fields
presetstring
todayyesterday7d30d90dthis_monthlast_monththis_yearall
fromstring
tostring

Responses

Each cohort's size and the people who came back in each period.

cohortsRetentionCohort[]required
Oldest first.
Show 4 fields
startstring · daterequired
The cohort's first day, in the project's time zone (a Monday for weeks, the 1st for months).
sizeintegerrequired
People in the cohort.
retainedinteger | null[]required
People who came back, per period from 0 (the cohort's own) to periods; null while the period hasn't started.
ratesnumber | null[]required
The same as a percent of size.
averagenumber | null[]required
Per period, the percent who came back over every cohort that has reached it; null when none has.
granularitystringrequired
dayweekmonth
periodsintegerrequired
count_bystringrequired
usersvisitors
date_rangeobjectrequired
A resolved range [from, to) in UTC.
Show 2 fields
fromstring · date-timerequired
A time in UTC, ISO 8601.
tostring · date-timerequired
A time in UTC, ISO 8601.
Example response
1{
2 "cohorts": [
3 {
4 "start": "2026-11-21",
5 "size": 1,
6 "retained": [
7 1
8 ],
9 "rates": [
10 1.5
11 ]
12 }
13 ],
14 "average": [
15 1.5
16 ],
17 "granularity": "day",
18 "periods": 1,
19 "count_by": "users",
20 "date_range": {
21 "from": "2026-11-21T09:30:00Z",
22 "to": "2026-11-21T09:30:00Z"
23 }
24}

Errors

Every error has the same shape: error.code, a message for people and details.

StatusCode
422validation_error
503clickhouse_not_configured