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

# Analytics events endpoint

> Use `/events` to submit analytics events such as `click` and `conversion` to Meilisearch.

## Send an event

**/events**

Send an analytics event to Meilisearch.

### Body

| Name | Type | Required | Description |
| :- | :- | :- | :- |
| `eventType` | String | Yes | The event type: `"click"` or `"conversion"` |
| `eventName` | String | Yes | A descriptive label for the event |
| `indexUid` | String | Yes | The index containing the document the user interacted with |
| `userId` | String | Yes | An arbitrary string identifying the user who performed the action |
| `queryUid` | String | Recommended | The [search query's UID](https://www.meilisearch.com/docs/reference/api/headers.md#search-metadata). Links the event to a specific search query |
| `objectId` | String | Recommended | The document's primary key value |
| `position` | Integer | Recommended | The document's position in the search result list (0-based). Only relevant for `click` events |
| `objectName` | String | No | A human-readable description of the document |

```json theme={null}
{
  "eventType": "click",
  "eventName": "Search Result Clicked",
  "indexUid": "products",
  "objectId": "0",
  "position": 0
}
```

> [!NOTE]
>
> You must provide a string identifying your user if you want Meilisearch to track conversion and click events.
>
> You may do that in two ways:
>
> * Specify the user ID in the payload, using the `userId` field
> * Specify the user ID with the `X-MS-USER-ID` header with your `/events` and search requests

#### Example

```bash cURL theme={null}
curl \
  -X POST 'https://PROJECT_URL/events' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer DEFAULT_SEARCH_API_KEY' \
  --data-binary '{
    "eventType": "click",
    "eventName": "Search Result Clicked",
    "indexUid": "products",
    "userId": "SEARCH_USER_ID",
    "queryUid": "019a01b7-a1c2-7782-a410-bb1274c81393",
    "objectId": "0",
    "objectName": "DOCUMENT_DESCRIPTION",
    "position": 0
  }'
```

##### Response: `201 Created`

## Next steps

> [card] [Get started with analytics](https://www.meilisearch.com/docs/capabilities/analytics/getting_started.md)
>
> Set up analytics and start collecting search data.

> [card] [Bind events to a user](https://www.meilisearch.com/docs/capabilities/analytics/how_to/bind_events_to_user.md)
>
> Associate analytics events with specific users for accurate tracking.

> [card] [Track click events](https://www.meilisearch.com/docs/capabilities/analytics/how_to/track_click_events.md)
>
> Configure your application to send click events to Meilisearch.


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