Skip to content

Ad-hoc retention/cohort calculation

projectId
required
string
Media typeapplication/json

Ad-hoc retention/cohort request. All fields optional; defaults from growth definition.

object
startEvent
string
returnEvent
string | null
granularity
string
Allowed values: day week month
cohortStart
string format: date
cohortEnd
string format: date
startDate
string format: date
endDate
string format: date
retentionDays
Array<integer>
segmentBy
string
analysisSubject
string
analysisSubjectKey
string | null

Retention matrix (dynamic shape). Some keys are dynamic — Two shapes discriminated by the literal segmented boolean, which is ALWAYS present. segmented=true only when body.segmentBy resolves to a valid dimension (utmSource | deviceType | visitorId | userId | sessionId | account). matrix[].retention is a DYNAMIC-KEYED map: keys are the stringified retention intervals actually requested (body.retentionDays, default [0,1,3,7,14,30]); values are percentages 0-100 rounded to 2 decimals. Keys therefore vary per request — modeled with additionalProperties: number, which is honest here. cohortDate is a date-only string “YYYY-MM-DD” (bucket start, UTC; week buckets snap to Monday, month buckets to the 1st). Matrix is sorted cohortDate DESC. headers are localized Chinese labels: index 0 is always “D0”, others are D{n}天 / D{n}周 / D{n}月 depending on granularity — same length/order as retentionDays. Errors (“起始事件不能为空”) return 400 {error: “计算失败”, detail: string}.

Media typeapplication/json
One of:
RetentionUnsegmented
object
segmented
required
boolean
matrix
required
Array<object>
object
cohortDate
required

Bucket start date “YYYY-MM-DD” (UTC).

string
cohortSize
required
integer
retention
required

Dynamic map: key = retention interval (stringified integer, matching retentionDays), value = percent 0-100 rounded to 2 decimals.

object
key
additional properties
number
curve
required
Array<object>
object
day
required

Retention interval (unit follows granularity).

integer
rate
required

Mean of the per-cohort rates for that interval; when no cohorts exist, 100 for day 0 and 0 otherwise.

number
headers
required
Array<string>
retentionDays
required
Array<integer>
_meta
required
object
scope
required
string
Allowed values: EVENT SESSION VISITOR IDENTIFIED_USER ACCOUNT
requestedScope
required
string
Allowed values: EVENT SESSION VISITOR IDENTIFIED_USER ACCOUNT
scopeLabel
required
string
analysisSubjectKey
required
string
nullable
segmentBy
required

Null when the request supplied no/invalid dimension.

string
nullable
Allowed values: utmSource deviceType visitorId userId sessionId account
entityLabel
required
string

Calculation failed / invalid body.

Media typeapplication/json
object
error
string
detail
string
Examplegenerated
json
{
"error": "example",
"detail": "example"
}