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

# Track Visitors

> Send website or app sessions, events and visitor identifiers.

Record anonymous visitor sessions and events. The tracking snippet from [Capturing Leads via API](https://docs.oktivo.com/guides/lead-capture.md) calls this endpoint for you. Call it directly from your own backend or app if you do not use the snippet.

Data is stored against the visitor first. This endpoint never creates a lead. If the visitor is already linked to a lead, their sessions and events are attached to that lead.

## Request Body

**visitorId** `string` *required*

A stable ID for the visitor, minted by you or the snippet.

**session** `object`

**session properties**

**sessionId** `string` *required*

Session ID. The session is only recorded when this is set.

**source** `string`

Traffic source.

**medium** `string`

Traffic medium.

**campaign** `string`

Campaign name.

**landingPage** `string`

First page URL.

**referrer** `string`

Referrer URL.

**device** `string`

Device type.

**browser** `string`

Browser name.

**startedAt** `string | number`

Session start as an ISO 8601 string or epoch milliseconds. Defaults to the time of the request.

**events** `array`

Up to 50 events per request; more returns `400`.

**event properties**

**eventId** `string` *required*

Your unique ID for the event. Sending the same `eventId` again is counted as a duplicate and not stored twice.

**eventName** `string` *required*

The event name, for example `page_view`.

**eventTime** `string | number`

When the event happened. Defaults to the time of the request.

**sessionId** `string`

Session the event belongs to. Defaults to `session.sessionId`.

**page** `object`

`url`, `path`, `title` and `referrer` of the page.

**properties** `object`

Free-form data. Larger than 8 KB once serialized and it is dropped.

**identifiers** `object`

Identifiers used to recognize the same visitor later: `ga4ClientId`, `cookie`, `deviceId`, `gclid`, `fbclid`, `gbraid`, `wbraid`, `fbp` and `fbc`.

An event without an `eventId` or `eventName` is skipped and the rest of the batch is still accepted. Text fields are trimmed and capped at 256 characters (2048 for URLs).

## Response

**success** `boolean`

Indicates if the request was accepted.

**data** `object`

**data properties**

**visitorId** `string`

The visitor ID.

**sessionRecorded** `boolean`

Whether a session was stored.

**eventsAccepted** `number`

New events stored.

**eventsDuplicated** `number`

Events ignored because their `eventId` was already stored.

**identifiersRecorded** `number`

Identifiers stored.

```bash cURL theme={null}
curl -X POST https://client-backend.oktivo.com/api/v1/crm/track \
  -H "Authorization: Bearer okt_YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "visitorId": "v_8f2c1a",
    "session": { "sessionId": "s_41", "source": "google", "medium": "cpc" },
    "events": [
      { "eventId": "e_1", "eventName": "page_view", "page": { "path": "/pricing" } }
    ],
    "identifiers": { "gclid": "Cj0KCQ..." }
  }'
```

```json 202 Accepted theme={null}
{
  "success": true,
  "data": {
    "visitorId": "v_8f2c1a",
    "sessionRecorded": true,
    "eventsAccepted": 1,
    "eventsDuplicated": 0,
    "identifiersRecorded": 1
  },
  "requestId": "3f1c2c0e-6a41-4e0b-9f0e-1f2d6f1b8a77",
  "timestamp": "2026-03-02T04:05:00.000Z"
}
```

```json 400 Validation Error theme={null}
{
  "success": false,
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "Invalid tracking payload",
    "validationErrors": [
      { "field": "visitorId", "message": "visitorId is required" }
    ]
  },
  "requestId": "3f1c2c0e-6a41-4e0b-9f0e-1f2d6f1b8a77",
  "errorInfo": {
    "code": "VALIDATION_ERROR",
    "message": "Invalid tracking payload",
    "details": [
      {
        "field": "visitorId",
        "message": "visitorId is required"
      }
    ]
  }
}
```

> [!NOTE]
>
> This endpoint accepts an **API Token** (`okt_...`) or **JWT**. The account is taken from the token, never from the request body. It requires the `crm_api` feature and shares the 120 requests/minute limit. The script `GET /api/v1/crm/track.js` is public and needs no token.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.