> ## Documentation Index
> Fetch the complete documentation index at: https://algolia.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Send events for Recommend analytics

> Learn which parameters to include in Recommend requests to attribute click and conversion events correctly.

Recommend analytics uses the same Insights API and event model as Search analytics.
For the concepts behind event tracking, see [Click and conversion events](/doc/guides/sending-events).
To choose an implementation path, see [Choose how to send events](/doc/guides/sending-events/getting-started).
This guide explains the Recommend-specific parameters to add to your requests so Algolia can assign click and conversion events to recommendations.

## Get started with Recommend analytics

To use Recommend analytics, include the parameters that link recommendation results to click and conversion events in your Recommend requests.

### Enable events collection

Set the [`clickAnalytics`](/doc/api-reference/api-parameters/clickAnalytics) parameter to `true` when making Recommend requests.
This adds the [`queryID`](/doc/guides/sending-events/guides/queryid) parameter to the Recommend response, which you need to link events to recommendations.

```js JavaScript icon=code theme={"system"}
const response = await client.getRecommendations({
  requests: [
    {
      // All models except `trending-facets` are supported.
      model: "related-products",
      indexName: "indexName",
      objectID: "objectID",
      threshold: 0,
      queryParameters: {
        clickAnalytics: true, // [!code ++]
      },
    },
  ],
});

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

For more information, see [Keep track of query IDs](/doc/guides/sending-events/guides/queryid).

### Send user tokens

User tokens are strings that uniquely identify users in your app.
They link click and conversion events to user profiles.
For more information, see [User token](/doc/guides/sending-events/concepts/usertoken).

```js JavaScript icon=code theme={"system"}
const response = await client.getRecommendations({
  requests: [
    {
      model: "related-products",
      indexName: "indexName",
      objectID: "objectID",
      threshold: 0,
      queryParameters: {
        clickAnalytics: true,
        userToken: "user-1234", // [!code ++]
      },
    },
  ],
});
```

### Add analytics tags (optional)

You can use [analytics tags](/doc/guides/search-analytics/guides/segments) to create different suggestions for different environments, such as mobile or desktop users, or for different geographical regions.

```js JavaScript icon=code theme={"system"}
const response = await client.getRecommendations({
  requests: [
    {
      model: "related-products",
      indexName: "indexName",
      objectID: "objectID",
      threshold: 0,
      queryParameters: {
        clickAnalytics: true,
        analyticsTags: ["front_end", "website2"], // [!code ++]
      },
    },
  ],
});
```

<Note>
  You can use `clickAnalytics`, `userToken` and `analyticsTags` parameters with
  all [API clients](/doc/libraries/sdk/methods/recommend/get-recommendations)
  and [UI libraries](/doc/ui-libraries). Pass these parameters in the Recommend
  request.
</Note>

## Send click and conversion events

After you enable `clickAnalytics` and send a `userToken` with your Recommend requests,
use the standard event flow to send click and conversion events.

* If you use InstantSearch, see [Send events (with InstantSearch)](/doc/guides/sending-events/instantsearch/send-events).
* If you use an API client, see [Send events (with an API client)](/doc/guides/sending-events/api-client/send-events).
