Skip to content

Ad-hoc funnel calculation

projectId
required
string
Media typeapplication/json

Ad-hoc funnel request. All fields optional; defaults filled from the saved growth definition.

object
steps

Event-name steps (>= 2 effective steps required after defaults).

Array<string>
windowHours
integer
startDate
string format: date
endDate
string format: date
filterBy
string
filterValue
string
breakdownBy
string
comparePeriod
boolean
analysisSubject
string
analysisSubjectKey
string | null
Examplegenerated
json
{
"steps": [
"example"
],
"windowHours": 1,
"startDate": "2026-04-15",
"endDate": "2026-04-15",
"filterBy": "example",
"filterValue": "example",
"breakdownBy": "example",
"comparePeriod": true,
"analysisSubject": "example",
"analysisSubjectKey": "example"
}

Funnel calculation result (dynamic shape). NOTE: the funnel calculate endpoint lives in routes/analytics.ts, NOT routes/funnels.ts (funnels.ts only does CRUD on saved funnel definitions). The 200 body is one of THREE mutually exclusive shapes, selected by request body: (a) body.comparePeriod === true -> {current, previous, change, _meta} (b) body.breakdownBy is a valid dimension -> {breakdown[], _meta} (c) otherwise -> the flat funnel result spread at top level {steps[], overall, _meta} Precedence in code: comparePeriod wins over breakdownBy. breakdownBy/filterBy are normalized against a fixed dimension whitelist (utmSource | deviceType | visitorId | userId | sessionId | account); anything else -> null. Rates are percentages 0-100, NOT rounded (raw float). avgTimeToNext is in SECONDS (0 when no transitions observed). Errors (incl. “至少需要2个步骤”) return 400 {error: “计算失败”, detail: string}.

Media typeapplication/json
One of:
FunnelPlain
object
steps
required
Array<object>
object
step
required

1-based step index.

integer
eventName
required
string
enteredCount
required
integer
completedCount
required

Subjects reaching the NEXT step; equals enteredCount on the last step.

integer
conversionRate
required

Percent 0-100

number
dropOffRate
required

Percent 0-100

number
avgTimeToNext
required

Average seconds from this step to the next; 0 when no transitions.

number
overall
required
object
totalEntered
required
integer
totalCompleted
required
integer
conversionRate
required

Percent 0-100

number
_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

Localized zh-CN label. e.g. “访客”.

string
analysisSubjectKey
required
string
nullable
filterBy
required

Null when the request supplied no/invalid dimension.

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

Null when the request supplied no/invalid dimension.

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

Localized zh-CN label. e.g. “访客”.

string
windowHours
required
number

Calculation failed / invalid body.

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