Skip to content

[algolia-insights] auth user token and product list viewed support #7791

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ redirect_from:
- '/connections/destinations/catalog/algolia/'
id: 63e52bea7747fbc311d5b872
---
With the [Algolia Insights (Actions)](https://www.algolia.com/products/analytics/){:target="_blank"} destination, you can send [Insights Events](https://www.algolia.com/doc/guides/sending-events/getting-started/){:target="_blank"}. It's required to send Insight Events to use these Algolia features:
With the Algolia Insights (Actions) destination, you can send [Insights Events](https://www.algolia.com/doc/guides/sending-events/getting-started/){:target="_blank"}. Insight Events are required to use these Algolia features:

- Click and conversion analytics
- A/B Testing
- AI Re-Ranking
- Personalization
- Algolia Recommend
- [Click and conversion analytics](https://www.algolia.com/doc/guides/search-analytics/overview/)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- [Click and conversion analytics](https://www.algolia.com/doc/guides/search-analytics/overview/)
- [Click and conversion analytics](https://www.algolia.com/doc/guides/search-analytics/overview/){:target="_blank"}

- [Algolia Recommend](https://www.algolia.com/doc/guides/algolia-recommend/overview/)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- [Algolia Recommend](https://www.algolia.com/doc/guides/algolia-recommend/overview/)
- [Algolia Recommend](https://www.algolia.com/doc/guides/algolia-recommend/overview/){:target="_blank"}

- [Personalization](https://www.algolia.com/doc/guides/personalization/classic-personalization/what-is-personalization/)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- [Personalization](https://www.algolia.com/doc/guides/personalization/classic-personalization/what-is-personalization/)
- [Personalization](https://www.algolia.com/doc/guides/personalization/classic-personalization/what-is-personalization/){:target="_blank"}

- [Dynamic Re-Ranking](https://www.algolia.com/doc/guides/algolia-ai/re-ranking/)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- [Dynamic Re-Ranking](https://www.algolia.com/doc/guides/algolia-ai/re-ranking/)
- [Dynamic Re-Ranking](https://www.algolia.com/doc/guides/algolia-ai/re-ranking/){:target="_blank"}

- [A/B Testing](https://www.algolia.com/doc/guides/ab-testing/what-is-ab-testing/)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- [A/B Testing](https://www.algolia.com/doc/guides/ab-testing/what-is-ab-testing/)
- [A/B Testing](https://www.algolia.com/doc/guides/ab-testing/what-is-ab-testing/){:target="_blank"}

- [Query Categorization](https://www.algolia.com/doc/guides/algolia-ai/query-categorization/)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- [Query Categorization](https://www.algolia.com/doc/guides/algolia-ai/query-categorization/)
- [Query Categorization](https://www.algolia.com/doc/guides/algolia-ai/query-categorization/){:target="_blank"}

- [NeuralSearch](https://www.algolia.com/doc/guides/getting-started/neuralsearch/)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- [NeuralSearch](https://www.algolia.com/doc/guides/getting-started/neuralsearch/)
- [NeuralSearch](https://www.algolia.com/doc/guides/getting-started/neuralsearch/){:target="_blank"}


This destination is maintained by [Algolia](https://www.algolia.com/){:target="_blank”}. For any issues with the destination, [contact the Algolia team](mailto:[email protected]).

Expand All @@ -25,7 +27,7 @@ This destination is maintained by [Algolia](https://www.algolia.com/){:target="_

### Getting your Algolia credentials

Your app ID and API key can be found in the **API Keys** section of your account settings in the Algolia dashboard. You will need a **search** API key to set up the destination.
Your app ID and API key can be found in the **API Keys** section of your account settings in the Algolia dashboard. You need a **search** API key to set up the destination.

![Dashboard Settings](images/algolia_dashboard_settings.png)

Expand All @@ -37,13 +39,19 @@ Your app ID and API key can be found in the **API Keys** section of your account

The Algolia Insights Destination is not a plug-and-play integration. It requires you to modify your frontend code to add additional Algolia-related data like an index name and a query ID.

To access your query ID, make sure [`clickAnalytics`](https://www.algolia.com/doc/api-reference/api-parameters/clickAnalytics/) is enabled in your searches. If you're using our JavaScript search API client, this will look like:
To access your query ID, make sure [`clickAnalytics`](https://www.algolia.com/doc/api-reference/api-parameters/clickAnalytics/) is enabled in your searches. If you're using our [JavaScript v5 search API client](https://www.algolia.com/doc/libraries/javascript/v5/methods/search/search-single-index/?client=javascript), this looks like:
Copy link
Contributor

@sade-wusi sade-wusi Jul 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
To access your query ID, make sure [`clickAnalytics`](https://www.algolia.com/doc/api-reference/api-parameters/clickAnalytics/) is enabled in your searches. If you're using our [JavaScript v5 search API client](https://www.algolia.com/doc/libraries/javascript/v5/methods/search/search-single-index/?client=javascript), this looks like:
To access your query ID, make sure [`clickAnalytics`](https://www.algolia.com/doc/api-reference/api-parameters/clickAnalytics/){:target="_blank"} is enabled in your searches. If you're using the [JavaScript v5 search API client](https://www.algolia.com/doc/libraries/javascript/v5/methods/search/search-single-index/?client=javascript){:target="_blank"}, this looks like:


```js
index.search('query', {
import { algoliasearch } from 'algoliasearch';

const client = algoliasearch('ALGOLIA_APPLICATION_ID', 'ALGOLIA_API_KEY');

const response = await client.searchSingleIndex({
indexName: '<INDEX_NAME>',
query: '<QUERY>',
userToken: 'user-1',
clickAnalytics: true
})
});
```

Once this is enabled, you will be able to access `queryID` in your search response, which you can then use in your Segment events.
Expand All @@ -52,7 +60,7 @@ You can read more about how to send Algolia-related data to Segment in the [Algo

## Mapping Events

By default, Algolia has set up mappings for `Product List Filtered`, `Product Clicked`, `Product Viewed`, `Product Added` and `Order Completed` events. If your event structure doesn't match Segment's [Ecommerce Spec](/docs/connections/spec/ecommerce/v2/), you can update this in the destination mappings section of the Segment app.
By default, Algolia has set up mappings for `Product List Filtered`, `Product List Viewed`, `Product Viewed`, `Product Clicked`, `Product Added` and `Order Completed` events. If your event structure doesn't match Segment's [Ecommerce Spec](/docs/connections/spec/ecommerce/v2/), you can update this in the destination mappings section of the Segment app.

![Mappings Tab](images/mappings_tab.png)

Expand All @@ -72,13 +80,17 @@ Algolia supports the following Segment events out of the box:
<td>Send this event when a visitor filters a product list or category.</td>
</tr>
<tr>
<td><code>Product Clicked</code></td>
<td>Fire this event when a visitor clicks a product.</td>
<td><code>Product List Viewed</code></td>
<td>Send this event when a visitor views a product list or category.</td>
</tr>
<tr>
<td><code>Product Viewed</code></td>
<td>Fire this event when a visitor views a product.</td>
</tr>
<tr>
<td><code>Product Clicked</code></td>
<td>Fire this event when a visitor clicks a product.</td>
</tr>
<tr>
<td><code>Product Added</code></td>
<td>Fire this event when a visitor adds a product to their shopping cart.</td>
Expand All @@ -104,10 +116,16 @@ analytics.track('Product List Filtered', {
// ... other required properties from the spec
})

analytics.track('Product Clicked', {
analytics.track('Product List Viewed', {
search_index: "my-index-name",
product_id: "hit objectID",
position: hitPositionOnIndex, // number
products: [
{
product_id: "hit objectID",
},
{
product_id: "hit objectID 2",
},
],
query_id: "Algolia queryID", // required only for Click Analytics,
// ... other required properties from the spec
})
Expand All @@ -119,6 +137,15 @@ analytics.track('Product Viewed', {
// ... other required properties from the spec
})

analytics.track('Product Clicked', {
search_index: "my-index-name",
product_id: "hit objectID",
position: hitPositionOnIndex, // number
query_id: "Algolia queryID", // required only for Click Analytics,
// ... other required properties from the spec
})

// This
analytics.track('Product Added', {
search_index: "my-index-name",
product_id: "hit objectID",
Expand Down