Skip to content

Goals and funnels

The conversion model behind the reports. Listing funnels and running one are on the read surface; these are the writes, plus the goal list that gives you ids to work with.

MethodPathPermission
GET/sites/{id}/goalsRead analytics
POST/sites/{id}/goalsManage sites
PUT/sites/{id}/goals/{goalId}Manage sites
DELETE/sites/{id}/goals/{goalId}Manage sites
POST/sites/{id}/funnelsManage sites
PUT/sites/{id}/funnels/{funnelId}Manage sites
DELETE/sites/{id}/funnels/{funnelId}Manage sites

Writes are owner only. A shared site answers 403 not_site_owner.

List goals

GET /api/v1/sites/{id}/goals

What the site measures, as configured. For how those goals performed, query the event:goal dimension through /query.

Create a goal

POST /api/v1/sites/{id}/goals

A goal is one of three things: a custom event, a page, or a scroll depth. Send the fields for one of them, not several.

FieldNotes
nameRequired. Shown in reports
event_nameA custom event the site sends
pathA page path, paired with operator
operatore equals, b begins with, c contains
scroll_depthPercent scrolled, 1 to 100
curl -s -X POST https://statable.com/api/v1/sites/3195799/goals \
  -H "Authorization: Bearer stbl_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name": "Signup", "path": "/thanks", "operator": "e"}'

A duplicate name is 409 goal_exists.

Replace a goal

PUT /api/v1/sites/{id}/goals/{goalId}

Sends the whole definition. A field you leave out is cleared, not kept, so read the goal first and send it back with your edit applied.

DELETE answers 204. Deleting one that is already gone is 404 goal_not_found.

Create a funnel

POST /api/v1/sites/{id}/funnels

An ordered list of two or more steps.

FieldNotes
nameRequired. A duplicate is 409 funnel_exists
stepsRequired, two or more
scopevisitor by default, or session
strict_orderWhen true the steps must occur in exactly this order with nothing between
curl -s -X POST https://statable.com/api/v1/sites/3195799/funnels \
  -H "Authorization: Bearer stbl_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name": "Signup flow",
       "steps": [{"kind": "page", "path": "/"},
                 {"kind": "goal", "goal_id": 12}]}'

Each step carries a kind, and that decides which other fields apply.

kindOther fields
pagepath, operator (e equals, b begins with, c contains, r regex)
entry_page exit_pagepath
eventevent, optionally prop_key and prop_value
goalgoal_id
scrollthe depth to reach

A step pointing at a goal this site does not have is 400, and the error names the step.

The answer has the same shape as GET /funnels, so a funnel you just created can be run through POST /funnels/{id}/report without fetching it again.

Replace a funnel

PUT /api/v1/sites/{id}/funnels/{funnelId}

Replaces the definition including every step. Steps you leave out are removed, not kept.

DELETE answers 204. An unknown id is 404 unknown_funnel.

strict_order changes what a report means

With it off, a visitor who did the steps in a different order still counts. Turn it on only when the sequence itself is the thing you are measuring, and remember that a saved funnel's reports before and after the change are not comparable.

Next steps

  • Manage sites for provisioning and settings
  • Goals for what a goal means in the dashboard
  • Errors for every code these endpoints return

Ready to take control of your web analytics? Try Statable free for 30 days. No credit card required, full feature access, built for GDPR. Start your free trial or view a live demo.