API reference
Goals API
Record a goal for a visitor from your server with POST /api/v1/goals: the request body, examples in curl, Node.js and Python, and the responses.
POST https://supranalytics.app/api/v1/goals
Records a goal for a visitor, attached to their latest visit. It shows up on the dashboard and in the live view, and sends goal alerts.
Body
| Field | Type | Description |
|---|---|---|
visitor_id | string, required | The visitor's id: the supr_visitor_id cookie. supr_visitor_id works as the name too. |
name | string, required | The goal's name. Lowercased, spaces become _, at most 64 characters. |
props | object | Up to 10 properties: keys up to 32 characters, values up to 255. metadata works as the name too. |
Example
curl -X POST https://supranalytics.app/api/v1/goals \
-H "Authorization: Bearer pk_YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{"visitor_id": "6f1c2a9e-…", "name": "signup", "props": {"plan": "pro"}}'await fetch("https://supranalytics.app/api/v1/goals", {
method: "POST",
headers: { Authorization: `Bearer ${process.env.SUPRANALYTICS_API_KEY}`, "Content-Type": "application/json" },
body: JSON.stringify({ visitor_id: req.cookies.supr_visitor_id, name: "signup", props: { plan: "pro" } }),
});requests.post(
"https://supranalytics.app/api/v1/goals",
headers={"Authorization": f"Bearer {os.environ['SUPRANALYTICS_API_KEY']}"},
json={"visitor_id": request.cookies.get("supr_visitor_id"), "name": "signup", "props": {"plan": "pro"}},
)Responses
| Status | Body |
|---|---|
200 | { "ok": true } |
400 | { "error": "visitor_id and name are required" } |
404 | { "error": "Visitor has no sessions yet" } |
AI agent or LLM? Read this page as Markdown