Skip to content

Commit 1e61450

Browse files
authored
Merge pull request #7791 from algolia/algolia-insights/update
[algolia-insights] auth user token and product list viewed support
2 parents 789a121 + 7a0e31d commit 1e61450

File tree

1 file changed

+47
-16
lines changed
  • src/connections/destinations/catalog/actions-algolia-insights

1 file changed

+47
-16
lines changed

src/connections/destinations/catalog/actions-algolia-insights/index.md

Lines changed: 47 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@ redirect_from:
55
- '/connections/destinations/catalog/algolia/'
66
id: 63e52bea7747fbc311d5b872
77
---
8-
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:
8+
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:
99

10-
- Click and conversion analytics
11-
- A/B Testing
12-
- AI Re-Ranking
13-
- Personalization
14-
- Algolia Recommend
10+
- [Click and conversion analytics](https://www.algolia.com/doc/guides/search-analytics/overview/){:target="_blank"}
11+
- [Algolia Recommend](https://www.algolia.com/doc/guides/algolia-recommend/overview/){:target="_blank"}
12+
- [Personalization](https://www.algolia.com/doc/guides/personalization/classic-personalization/what-is-personalization/){:target="_blank"}
13+
- [Dynamic Re-Ranking](https://www.algolia.com/doc/guides/algolia-ai/re-ranking/){:target="_blank"}
14+
- [A/B Testing](https://www.algolia.com/doc/guides/ab-testing/what-is-ab-testing/){:target="_blank"}
15+
- [Query Categorization](https://www.algolia.com/doc/guides/algolia-ai/query-categorization/){:target="_blank"}
16+
- [NeuralSearch](https://www.algolia.com/doc/guides/getting-started/neuralsearch/){:target="_blank"}
1517

1618
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]).
1719

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

2628
### Getting your Algolia credentials
2729

28-
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.
30+
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.
2931

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

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

3840
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.
3941

40-
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:
42+
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:
4143

4244
```js
43-
index.search('query', {
45+
import { algoliasearch } from 'algoliasearch';
46+
47+
const client = algoliasearch('ALGOLIA_APPLICATION_ID', 'ALGOLIA_API_KEY');
48+
49+
const response = await client.searchSingleIndex({
50+
indexName: '<INDEX_NAME>',
51+
query: '<QUERY>',
4452
userToken: 'user-1',
4553
clickAnalytics: true
46-
})
54+
});
4755
```
4856

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

5361
## Mapping Events
5462

55-
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.
63+
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.
5664

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

67+
### User identifiers
68+
69+
When mapping user identifiers, Algolia recommends using the **Authenticated User Token** field to map authenticated user IDs and the **User Token** field for anonymous user IDs. For more detail, see the [Algolia documentation](https://www.algolia.com/doc/guides/sending-events/concepts/usertoken/#persistent-user-token){:target="_blank"}.
70+
5971
## Track
6072

6173
If you're not familiar with the Segment spec, take a look to understand what the [Track](/docs/connections/spec/track/) method does.
@@ -72,13 +84,17 @@ Algolia supports the following Segment events out of the box:
7284
<td>Send this event when a visitor filters a product list or category.</td>
7385
</tr>
7486
<tr>
75-
<td><code>Product Clicked</code></td>
76-
<td>Fire this event when a visitor clicks a product.</td>
87+
<td><code>Product List Viewed</code></td>
88+
<td>Send this event when a visitor views a product list or category.</td>
7789
</tr>
7890
<tr>
7991
<td><code>Product Viewed</code></td>
8092
<td>Fire this event when a visitor views a product.</td>
8193
</tr>
94+
<tr>
95+
<td><code>Product Clicked</code></td>
96+
<td>Fire this event when a visitor clicks a product.</td>
97+
</tr>
8298
<tr>
8399
<td><code>Product Added</code></td>
84100
<td>Fire this event when a visitor adds a product to their shopping cart.</td>
@@ -104,10 +120,16 @@ analytics.track('Product List Filtered', {
104120
// ... other required properties from the spec
105121
})
106122

107-
analytics.track('Product Clicked', {
123+
analytics.track('Product List Viewed', {
108124
search_index: "my-index-name",
109-
product_id: "hit objectID",
110-
position: hitPositionOnIndex, // number
125+
products: [
126+
{
127+
product_id: "hit objectID",
128+
},
129+
{
130+
product_id: "hit objectID 2",
131+
},
132+
],
111133
query_id: "Algolia queryID", // required only for Click Analytics,
112134
// ... other required properties from the spec
113135
})
@@ -119,6 +141,15 @@ analytics.track('Product Viewed', {
119141
// ... other required properties from the spec
120142
})
121143

144+
analytics.track('Product Clicked', {
145+
search_index: "my-index-name",
146+
product_id: "hit objectID",
147+
position: hitPositionOnIndex, // number
148+
query_id: "Algolia queryID", // required only for Click Analytics,
149+
// ... other required properties from the spec
150+
})
151+
152+
// This
122153
analytics.track('Product Added', {
123154
search_index: "my-index-name",
124155
product_id: "hit objectID",

0 commit comments

Comments
 (0)