Documentation menuAPI: Goals

API

Goals endpoints

These endpoints read and manage goals. Reading needs goals:read, and changing needs goals:write. Public sites and private links can read the list.

Last updated . This guide belongs to Custom events and goals.

GET /sites/:siteId/goals

ParameterMeaningDefault
page, page_sizePaging. Maximum 1001, 10
sortgoalId, name, goalType or createdAtcreatedAt
orderasc or descdesc

The shared time parameters, filters and segment_id change the conversion numbers, not the list of goals.

{ "data": [ { "goalId": 12, "name": "Signup", "goalType": "event", "config": { "eventName": "signup_completed" }, "total_conversions": 184, "total_sessions": 5120, "conversion_rate": 0.0359 } ], "meta": { "total": 4, "page": 1, "pageSize": 10, "totalPages": 1 } }

conversion_rate is a fraction from 0 to 1.

How do you create or change a goal?

RequestResult
POST /sites/:siteId/goalsCreates a goal. Status 201 with goalId
PUT /sites/:siteId/goals/:goalIdReplaces the whole goal
DELETE /sites/:siteId/goals/:goalIdDeletes it
FieldRequiredContent
goalTypeYespath, event, outbound, button_click, form_submit or copy
nameNoA label
config.pathPatternFor pathA path. * matches one segment and ** matches anything
config.eventNameFor eventThe exact event name
config.valuePatternNoFor the captured types. Up to 512 characters
config.propertyFiltersNoA list of { key, value }. All must match

Which other goal endpoints are there?

EndpointReturns
GET /sites/:siteId/goals/time-seriesConversions per bucket. Send goal_ids as a comma-separated list
GET /sites/:siteId/goals/:goalId/sessionsThe sessions that reached the goal. Not available for public sites