Skip to content

Insights, Analytics and Personalization

Sarah Dayan edited this page Jul 24, 2020 · 1 revision

We provide you with ways to measure how your search is doing, and make search results more relevant for individual users by personalizing their experience based on a unique profile built over time.

googleAnalytics

boolean

Whether to send events to Google Analytics when queries are triggered.

It assumes that you've already installed the Google Analytics tag on your website, and that the global Google Analytics object ga is available on window.

setUserToken

(setToken: (userToken: string) => void) => void

A function to set the userToken of the current user and allow Personalization.

Make sure you have access to Personalization on your Algolia plan.

Example:

const config = {
  // ...
  setUserToken(setToken) {
    // Assuming you store the `userToken` in a global variable
    setToken(window.ALGOLIA_USER_TOKEN);
    // Or if you store the `userToken` in an external API
    fetchTokenAsynchronously().then(({ token }) => setToken(token));
  },
};