Skip to content

POST /track/session/end

Ends a tracking session, calculates the final engagement score, and persists it.

Request Body

json
{
  "session_id": "550e8400-e29b-41d4-a716-446655440000",
  "visitor_id": "a1b2c3d4e5f6...",
  "exit_page": "https://example.com/about",
  "timestamp": 1740000060000
}
FieldRequiredDescription
session_idYesSession ID to end
exit_pageNoLast page the user was on
visitor_idNoVisitor ID
timestampNoEnd timestamp (defaults to Date.now())

Response (200)

json
{
  "session_id": "550e8400-e29b-41d4-a716-446655440000",
  "ended_at": 1740000060000
}

Background Processing

  1. Update session record: set ended_at, exit_page, compute duration
  2. Calculate final engagement score from all session events
  3. Persist engagement score to session record

Errors

StatusCondition
400Invalid JSON body
400Missing session_id