Requirements
- A Meilisearch Cloud project
- A method for identifying users
- A pipeline for submitting analytics events
Assign user IDs to search requests
You can assign user IDs to search requests by including anX-MS-USER-ID header with your query:
SEARCH_USER_ID with any value that uniquely identifies that user. This may be an authenticated user’s ID when running searches from your own back end, or a hash of the user’s IP address.
Assigning user IDs to search requests is optional. If a Meilisearch Cloud search request does not have an ID, Meilisearch will automatically generate one.
Assign user IDs to analytics events
You can assign a user ID to analytics/events in two ways: HTTP headers or including it in the event payload.
If using HTTP headers, include an X-MS-USER-ID header with your query:
userId field with your request:
Replace SEARCH_USER_ID with any value that uniquely identifies that user. This may be an authenticated user’s ID when running searches from your own back end, or a hash of the user’s IP address.
It is mandatory to specify a user ID when sending analytics events.
Conclusion
In this guide you have seen how to bind analytics events to specific users by specifying an HTTP header for the search request, and either an HTTP header or auserId field for the analytics event.