API Reference / API Parameters / userToken
Type: string
Engine default: user ip address
Parameter syntax
userToken: 'YourCustomUserId'

Can be used in these methods:
search, browseObjects, searchForFacetValues, generateSecuredApiKey, addApiKey, updateApiKey

About this parameter# A

Associates a certain user token with the current search.

Sending a user token will associate a search with a certain user. The insights taken from this could be used in combination with personalization for example. The user token has to be an alpha-numeric string with a maximum amount of 64 characters.

Examples# A

Set the user token#

1
2
3
4
5
index.search('query', {
  userToken: '123456'
}).then(({ hits }) => {
  console.log(hits);
});

Enable personalization for the current search and specify a user token#

1
2
3
4
5
6
index.search('query', {
  enablePersonalization: true,
  userToken: '123456'
}).then(({ hits }) => {
  console.log(hits);
});
Did you find this page helpful?
JavaScript v4