Guides / Algolia Recommend / Analytics

Send events for Recommend analytics

Recommend Analytics is a beta feature according to the Algolia Terms of Service (“Beta Services”).

Events are actions that users take on your app or website. They unlock powerful analytics that help you optimize your user experience.

With the Insights API, you can capture all important events related to your search and discovery experience.

If you are familiar with Search analytics, you will find that many of the concepts and metrics are similar, but if this is the first time you are sending events to Algolia, see Get started with events.

Start your implementation

The best way to send events to Algolia depends on where you’re sending them from. Algolia provides tools to help you make sure your events have all the necessary details.

Client-side versus server-side events

It’s best to send events straight from your users’ devices. To do this, see Send events from your frontend.

If you’re not collecting enough events compared to the number of visitors to your website or app, it might be because your users use ad blockers. In this case, consider server-side tracking.

Get started with Algolia Recommend analytics

Algolia Recommend Analytics is built on the same foundational concepts as Search Analytics and should feel familiar if you’ve used it before.

Get a queryID for your Recommend request

The queryID is a random sequence of letters and numbers that uniquely identifies a search request. Algolia generates the query ID and includes it in the Recommend API response if you set clickAnalytics to true when making the Recommend request.

For more information, see What is a query id and Keep track of query IDs.

Send a userToken

User tokens are strings that uniquely identify users throughout your app. They link click and conversion events with user profiles. For more information, see user token.

These parameters should be passed to the Recommend request. For the full technical documentation, see get recommendations.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
const response = await client.getRecommendations({
  requests: [
    {
      // all models are supported, except `trending-facets`
      model: "related-products",
      indexName: "indexName",
      objectID: "objectID",
      threshold: 0,
      queryParameters: { clickAnalytics: true, userToken: "user-1234" },
    },
  ],
});

// Use this queryID when sending click and conversion events
const queryID = response.results[0].queryID;

Send click and conversion events

To get the most out of your Recommend analytics, start collecting click and conversion events with the Algolia Insights API.

If you use Recommend with InstantSearch, see Send events with InstantSearch.

If you use the API clients, see Send events with the API clients.

Did you find this page helpful?