Skip to main content
Required ACL: search Use this method to keep track of the anonymous user token generated by the Insights API Client. For more information, see User token.

Examples

For more information about initializing the JavaScript Insights client aa, see Initialize the Insights client.
JavaScript
import aa from "search-insights";

aa("init", {
  appId: "YourApplicationID",
  apiKey: "YourSearchOnlyAPIKey",
});
Then, retrieve the generated user token.
JavaScript
aa("getUserToken", {}, (err, userToken) => {
  if (err) {
    console.error(err);
    return;
  }

  console.log(userToken);
});

Parameters

callback
(err: Error, userToken: string) => void
The function called with a possible error and the user token.
options
object
The options for retrieving the user token.Pass an empty object, since this argument isn’t used.
⌘I