The aggregation of the queries to retrieve the latest query, and thus the analytics results, looks at either the user's IP or their userToken
.
By default, our engine takes the user’s IP address as their unique identifier. However, you should not rely on this behavior. We recommend that you explicitly create a unique user identifier that you can keep track of in your own application. The user identifier can be sent to Algolia with the userToken parameter, or with the X-Algolia-UserToken
request header.
1 |
X-Algolia-UserToken: UID_OF_THE_END_USER |
If you’re doing back-end search from a server, the IP address will always be the same. In this scenario, you may want to forward the IP address of your user to your server. This way, it can be used for analytics purposes and to determine relevant results based on geolocation. To forward a user’s IP address to Algolia, you can use the X-Forwarded-For
header.
1 |
X-Forwarded-For: IP_OF_THE_END_USER |