Skip to main content

Get KPI

Returns a single Key Performance Indicator (KPI) for the given funnel and time window.

GET /v1/funnels/{funnelId}/metrics/kpis/{subtype}

Authentication

Requires the x-perspective-api-key header. See Authentication for details.

Path parameters

NameTypeRequiredDescription
funnelIdstringYesThe ID of the funnel to query.
subtypestringYesThe KPI type to retrieve. See Valid KPI subtypes below.

Query parameters

NameTypeRequiredDescription
fromstring (ISO 8601)YesStart of the metrics period, e.g. 2025-01-01T00:00:00.000Z. Must be before to.
tostring (ISO 8601)YesEnd of the metrics period, e.g. 2025-01-31T00:00:00.000Z.
offsetstringNoTimezone offset in minutes, e.g. -120 for UTC−2. Accepts an optional leading + or -.

Valid KPI subtypes

subtypeWhat it measuresUnit
kpi_conversion_ratePercentage of visitors who convert (become contacts)%
kpi_completion_ratePercentage of visitors who complete the entire funnel%
kpi_average_time_on_pageAverage time visitors spend on each pageseconds
kpi_time_to_completionAverage time from first page view to funnel completionseconds
kpi_new_contactsNumber of new contacts created in the periodcount
kpi_total_sessionsTotal number of visitor sessions in the periodcount
kpi_messages_sentTotal number of automated messages sent in the periodcount
kpi_messages_delivery_ratePercentage of automated messages delivered to contacts%
kpi_messages_open_ratePercentage of automated messages opened by contacts%

Example request

curl "https://api.perspective.co/v1/funnels/fnl_abc123/metrics/kpis/kpi_conversion_rate?from=2025-01-01T00:00:00.000Z&to=2025-01-31T00:00:00.000Z" \
-H "x-perspective-api-key: $PERSPECTIVE_API_KEY"

Response

Returns { data: KpiData }.

KpiData object

FieldTypeDescription
typestringThe KPI subtype name in camelCase (e.g. kpiConversionRate).
valuenumberThe computed KPI value. For rate-based KPIs (e.g. kpi_conversion_rate, kpi_completion_rate, kpi_messages_delivery_rate, kpi_messages_open_rate) this is a percentage. For time-based KPIs (e.g. kpi_average_time_on_page, kpi_time_to_completion) this is a duration in seconds. For count-based KPIs (e.g. kpi_new_contacts, kpi_total_sessions, kpi_messages_sent) this is a raw integer count.
countnumberTotal number of events or occurrences used to compute a rate-based KPI. Present only for rate-based KPIs.

Example response

{
"data": {
"type": "kpiConversionRate",
"value": 12.5,
"count": 150
}
}

Errors

See Errors for the full list of status codes and handling guidance.

StatusMeaning
400Missing or invalid parameters, or the requested KPI type was not found for this funnel.
401Missing or invalid API key.
403Your API key does not have metrics:read permission.
500Internal server error.