Skip to main content

Send an event

Send an analytics event to Meilisearch.

Body

NameTypeRequiredDescription
eventTypeStringYesThe event type: "click" or "conversion"
eventNameStringYesA descriptive label for the event
indexUidStringYesThe index containing the document the user interacted with
userIdStringYesAn arbitrary string identifying the user who performed the action
queryUidStringRecommendedThe search query’s UID. Links the event to a specific search query
objectIdStringRecommendedThe document’s primary key value
positionIntegerRecommendedThe document’s position in the search result list (0-based). Only relevant for click events
objectNameStringNoA human-readable description of the document
{
  "eventType": "click",
  "eventName": "Search Result Clicked",
  "indexUid": "products",
  "objectId": "0",
  "position": 0
}
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

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

Get started with analytics

Set up analytics and start collecting search data.

Bind events to a user

Associate analytics events with specific users for accurate tracking.

Track click events

Configure your application to send click events to Meilisearch.