> ## Documentation Index
> Fetch the complete documentation index at: https://docs.raykoi.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Track an Event

> Record a view, start, or submit event for a form's analytics.

The SDK and `submit.js` call this automatically — a `view` when the form loads, `start` on the first field interaction, and `submit` after a successful submission (carrying the same session/visitor identity so the resulting analytics row correlates back to the same visit). You only need this directly if you're building fully custom analytics or a headless integration that skips the SDK.

<ParamField path="public_id" type="string" required>
  The form's public ID.
</ParamField>

<ParamField body="event_type" type="string" required>
  One of `view`, `start`, `submit`.
</ParamField>

<ParamField body="session_id" type="string">
  Client-generated session identifier (typically from `sessionStorage`) — ties a view/start/submit sequence together as one visit.
</ParamField>

<ParamField body="visitor_id" type="string">
  Client-generated, longer-lived visitor identifier (typically from `localStorage`) — distinguishes a repeat visitor from a new one across sessions.
</ParamField>

Device type and browser are derived server-side from the User-Agent header — never trust or accept a client-supplied value for either.

This endpoint always responds `200` immediately and never blocks on the underlying write — analytics tracking is fire-and-forget by design, so a slow or failed write here can never make a form feel unresponsive.

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST "https://api.raykoi.com/api/v1/forms/p/YOUR_PUBLIC_ID/events" \
    -H "Content-Type: application/json" \
    -d '{"event_type": "view", "session_id": "sess_abc", "visitor_id": "vis_xyz"}'
  ```
</RequestExample>
