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

# Receive widget analytics events

> Sent when analyticsBaseUrl is set, as POST {base}/analytics (override with analyticsEndpoint)…

Sent when `analyticsBaseUrl` is set, as `POST &#123;base&#125;/analytics` (override with `analyticsEndpoint`). One event per user, assistant, commerce, handoff and lifecycle action, with `funnelStage` on outcomes.

### Request body

`AnalyticsEvent`

<ParamField body="action" type="string" required>
  e.g. `message_sent`, `cart_added`, `checkout_redirect`, `handoff_request`, `conversation_end`
</ParamField>

<ParamField body="sessionId" type="string" required />

<ParamField body="orgId" type="string" />

<ParamField body="agentId" type="string" />

<ParamField body="channel" type="string" />

<ParamField body="provider" type="string" />

<ParamField body="threadId" type="string" />

<ParamField body="conversationId" type="string" />

<ParamField body="pageUrl" type="string" />

<ParamField body="referrer" type="string" />

<ParamField body="data" type="object" />

<ParamField body="timestamp" type="string (date-time)" required />

<ParamField body="customFields" type="object" />

### Response

`Ok`

<ResponseField name="ok" type="boolean" required />

### Status codes

| Code  | Meaning |
| ----- | ------- |
| `200` | OK      |
| `400` | Error   |
| `401` | Error   |

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
    --url 'https://api.example.com/analytics' \
    --header 'x-widget-token: YOUR_API_KEY' \
    --header 'Content-Type: application/json' \
    --data '{
    "action": "string",
    "sessionId": "string",
    "orgId": "string",
    "agentId": "string",
    "channel": "string",
    "provider": "string",
    "threadId": "string",
    "conversationId": "string",
    "pageUrl": "string",
    "referrer": "string",
    "data": {
      "intent": "string",
      "messageId": "string",
      "messageType": "string",
      "sender": "string",
      "characterCount": 1.5,
      "responseTime": 1.5,
      "streamed": true,
      "funnelStage": "string"
    },
    "timestamp": "2026-08-31T14:22:05Z",
    "customFields": {}
  }'
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "ok": true
  }
  ```
</ResponseExample>
