Skip to main content
Track custom goal events server-side using the API.

Endpoint

POST /api/v1/goal

Authentication

Requires API key authentication.

Request body

FieldTypeRequiredDescription
eventstringYesThe goal event name
valuenumberNoOptional numeric value
visitorIdstringNoVisitor ID (if available)
sessionIdstringNoSession ID (if available)
pathstringNoPage path (defaults to ”/“)

Request example

curl -X POST "https://your-domain.com/api/v1/goal" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "event": "newsletter_signup",
    "value": 0,
    "visitorId": "visitor_123",
    "sessionId": "session_456",
    "path": "/newsletter"
  }'

Response

Success response (200)

{
  "status": "success",
  "data": {
    "message": "Goal event tracked successfully"
  }
}

Error responses

Missing event (400)

{
  "status": "error",
  "error": {
    "code": 400,
    "message": "event parameter is required"
  }
}

Unauthorized (401)

{
  "status": "error",
  "error": {
    "code": 401,
    "message": "Unauthorized. Invalid or missing API key."
  }
}

Use cases

  • Server-side tracking - Track events from your backend
  • Webhook handlers - Track goals from webhook events
  • Background jobs - Track goals from scheduled tasks
  • API integrations - Track goals from third-party APIs

Examples

Track purchase

curl -X POST "https://your-domain.com/api/v1/goal" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "event": "purchase",
    "value": 99.99,
    "visitorId": "visitor_123",
    "path": "/checkout/success"
  }'

Track form submission

curl -X POST "https://your-domain.com/api/v1/goal" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "event": "form_submit",
    "visitorId": "visitor_123",
    "path": "/contact"
  }'

Next steps

POST Payment

Learn how to record payments via API