Introduction
If you’re not using InstantSearch, you’ll have to send events using one of our API Clients.
All API Clients have methods to make sending events as simple as possible, requiring only a few lines of code.
We recommend sending personalization events using InstantSearch if you have an InstantSearch implementation.
Personalization events are not taken into account right away. User profiles will be updated roughly every 10 minutes.
The use-case scenario
We’re going to take an online bookshop as an example. The scenario will be as follows: our user, John, has an account with our online bookshop, with a unique user ID of user-123456
.
We want John to take a lot of actions on our website. The more he does, the more accurate his preferences will be. So we’ll send events on many different actions, like clicking, buying, adding to cart, etc. If you track only buy events, you’ll get less data than if you also send click and add-to-cart events.
So, John starts looking for children’s books like Harry Potter books. Tomorrow he looks for books on European history. And for the next weeks and months, he consistently focuses on history and children’s books. We want to capture all af that activity, so that whenever John searches, his results reflect those preferences.
The analytic-to-personalization workflow
Before getting started with personalization, you should already have implemented click and conversion analytics. That’s because you want to start collecting click-analytic data as soon as possible. Analytics data gets you focused on the basics - to improve your users’ search experience by making the best configuration and data formatting choices.
This is the preferred workflow: first, put click analytics in place; only after that do you want to to think about personalizing your users’ results. Additionally, click events create a foundation for A/B testing.
Our insights API, which manages all analytics and personalization events, reflects this workflow in its naming convention and parameters. Some methods are designed to track a user’s activity after a search (these have the suffix “AfterSearch”), and some methods are used only within the personalization context.
Insights events (click, conversion, view) used for analytics and/or personalization do not take immediate effect. The delay can range from 10 to 60 minutes depending on how long after the search they are sent. For precise times, see our page on when Insights events take effect.
We organize our event process to align with this workflow, by separating events into search-related events and non-search-related events.
Some events are meaningful only within the context of a search. These are typically click and conversion events. As you’ll see, the main two methods for sending search-related events are:
Because these events can be traced back to a query, they require a queryID
.
Getting the queryID
Every keystroke executes a query on Algolia’s servers and returns a set of results. Every set of results contains a unique queryID
.
When sending personalization events, we always use the latest queryID
. A query for “Harry Potter” is broken down as follows:
- The first keystroke (for the character ‘H’) has
aef12442b87e97ac
as queryID
.
- The second key stroke (for the characters ‘Ha’) has
cba8245617aeace44
as queryID
.
- The third … and so on.
You need to set clickAnalytics=true
in your query parameters for the queryID
to be included in the search results.
The queryID
, objectID
, and userToken
in this example are all fake. Don’t copy-paste these examples, change them according to your needs!
Sending Click Events
Whenever John clicks on a result, which is a search-related activity, we have two options:
-
Send an event using the ClickedObjectIdsAfterSearch method, which tracks the Click Through Rate (CTR) and can be used for personalization purposes.
-
Send an event using the ClickedObjectIds method, which only contributes towards personalization purposes.
Since this tutorial is on personalization, we can use both. However, we’ll want to choose the first option because it will do both click analytics and personalization in the same call.
In this example, the objectID
of the clicked-on book is 9780545139700
. We named our click event book_click_on_search_page
.
1
2
3
4
5
6
7
8
9
10
11
12
| $insights = Algolia\AlgoliaSearch\InsightsClient::create(
'YourApplicationID',
'YourSearchOnlyAPIKey'
);
$insights->user("user-123456")->clickedObjectIDsAfterSearch(
'book_click_on_search_page',
'my_online_bookshop_index',
['9780545139700'],
[7],
'cba8245617aeace44'
);
|
1
2
3
4
5
6
7
8
9
10
11
12
| insights = Algolia::Insights.new(
'YourApplicationID',
'YourSearchOnlyAPIKey'
)
insights.user('user-123456').clicked_object_ids_after_search(
'book_click_on_search_page',
'my_online_bookshop_index',
['9780545139700'],
[7],
'cba8245617aeace44'
)
|
1
2
3
4
5
6
7
8
9
10
11
12
| // This requires installing the search-insights separate library:
// https://github.com/algolia/search-insights.js
// https://www.npmjs.com/package/search-insights
aa('clickedObjectIDsAfterSearch', {
userToken: 'user-123456',
eventName: "book_click_on_search_page',
index: 'my_online_bookshop_index'
queryID: 'cba8245617aeace44',
objectIDs: ['9780545139700'],
positions: [7],
});
|
1
2
3
4
5
6
7
8
9
| insights = client.init_insights_client().user('user-123456')
insights.clicked_object_ids_after_search(
'book_click_on_search_page',
'my_online_bookshop_index',
['9780545139700'],
['7l'],
'cba8245617aeace44'
)
|
1
2
3
4
5
6
7
8
9
10
11
12
13
| Insights.register(
appId: "YourApplicationID",
apiKey: "YourSearchOnlyAPIKey",
userToken: "user-123456"
)
Insights.shared?.clickedAfterSearch(
eventName: "book_click_on_search_page",
indexName: "my_online_bookshop_index",
objectIDs: ["9780545139700"],
positions: [7],
queryID: "cba8245617aeace44"
)
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| Insights.register(
context,
"YourApplicationID",
"YourSearchOnlyAPIKey",
"user-123456"
)
Insights.shared?.clickedAfterSearch(
"book_click_on_search_page",
"my_online_bookshop_index",
"cba8245617aeace44",
EventObjects.IDs("9780545139700"),
listOf(7)
)
|
1
2
3
4
5
6
7
8
9
10
11
12
| var insights = new InsightsClient(
"YourApplicationID",
"YourSearchOnlyAPIKey"
).User("user-123456");
insights.ClickedObjectIDsAfterSearch(
"book_click_on_search_page",
"my_online_bookshop_index",
new List<string> { "9780545139700" },
new List<uint> { 7 },
"cba8245617aeace44"
);
|
1
2
3
4
5
6
7
8
9
10
11
12
13
| AsyncUserInsightsClient insights = new AsyncInsightsClient(
"YourApplicationID",
"YourSearchOnlyAPIKey",
client
).user("user-123456");
insights.clickedObjectIDsAfterSearch(
"book_click_on_search_page",
"my_online_bookshop_index",
Arrays.asList("9780545139700"),
new ArrayList<>(Arrays.asList(7l)),
"cba8245617aeace44"
);
|
1
2
3
4
5
6
7
8
9
10
11
12
| client := insights.NewClient(
"YourApplicationID",
"YourSearchOnlyAPIKey",
).User("user-123456")
res, err := client.ClickedObjectIDsAfterSearch(
"book_click_on_search_page",
"my_only_bookshop_index",
[]string{"9780545139700"},
[]int{7},
"cba8245617aeace44",
)
|
1
2
3
4
5
6
7
8
9
10
| client.execute {
send event ClickedObjectIDsAfterSearch(
"user-123456",
"book_click_on_search_page",
"my_online_bookshop_index",
Seq("9780545139700"),
Seq(7),
"cba8245617aeace44"
)
}
|
You can also send click events only for personalization by using the same function without the “AfterSearch” suffix. See ClickedObjectIds.
Sending Conversion Events
For conversion events, you have the same choice - either you send a conversion with a query id or not. If there is no query id, then the event serves only to record personalization data; if you send it with the query id, then you get both personalization and analytics.
Let’s say John sees Harry Potter books in his search results and decides to add the last two books to his favorites. For our bookshop, adding a product to the favorites is the action we had designated as a conversion event. Book number six has an objectID
of 9780439785969
, and book number seven has an objectID
of 9780545139700
.
We want to send a conversion that feeds both conversion analytics and personalization: ConvertedObjectIdsAfterSearch. In this example, we called our conversion event book_favorite_on_search_page
.
1
2
3
4
5
6
7
8
9
10
11
| $insights = Algolia\AlgoliaSearch\InsightsClient::create(
'YourApplicationID',
'YourSearchOnlyAPIKey'
);
$insights->user("user-123456")->convertedObjectIDsAfterSearch(
'book_favorite_on_search_page',
'my_online_bookshop_index',
['9780545139700', '9780439785969'],
'cba8245617aeace44'
);
|
1
2
3
4
5
6
7
8
9
10
11
| insights = Algolia::Insights.new(
'YourApplicationID',
'YourSearchOnlyAPIKey'
)
insights.user('user-123456').converted_object_ids_after_search(
'book_favorite_on_search_page',
'my_online_bookshop_index',
['9780545139700', '9780439785969'],
'cba8245617aeace44'
)
|
1
2
3
4
5
6
7
8
9
10
11
| // This requires installing the search-insights separate library
// https://github.com/algolia/search-insights.js
// https://www.npmjs.com/package/search-insights
aa('convertedObjectIDsAfterSearch', {
userToken: 'user-123456',
index: 'my_online_bookshop_index',
eventName: 'book_click_on_search_page',
queryID: 'cba8245617aeace44',
objectIDs: ['9780545139700', '9780439785969']
});
|
1
2
3
4
5
6
7
8
| insights = client.init_insights_client().user('user-123456')
insights.converted_object_ids_after_search(
'book_favorite_on_search_page',
'my_online_bookshop_index',
['9780545139700', '9780439785969'],
'cba8245617aeace44'
)
|
1
2
3
4
5
6
7
8
9
10
11
12
| Insights.register(
appId: "YourApplicationID",
apiKey: "YourSearchOnlyAPIKey",
userToken: "user-123456"
)
Insights.shared?.convertedAfterSearch(
eventName: "book_favorite_on_search_page",
indexName: "my_online_bookshop_index",
objectIDs: ["9780545139700", "9780439785969"],
queryID: "cba8245617aeace44"
)
|
1
2
3
4
5
6
7
8
9
10
11
12
13
| Insights.register(
context,
"YourApplicationID",
"YourSearchOnlyAPIKey",
"user-123456"
)
Insights.shared?.convertedAfterSearch(
"book_favorite_on_search_page",
"my_online_bookshop_index",
"cba8245617aeace44",
EventObjects.IDs("9780545139700", "9780439785969")
)
|
1
2
3
4
5
6
7
8
9
10
11
| var insights = new InsightsClient(
"YourApplicationID",
"YourSearchOnlyAPIKey"
).User("user-123456");
insights.ConvertedObjectIDsAfterSearch(
"book_favorite_on_search_page",
"my_online_bookshop_index",
new List<string> { "9780545139700", "9780439785969" },
"cba8245617aeace44"
);
|
1
2
3
4
5
6
7
8
9
10
11
12
| AsyncUserInsightsClient insights = new AsyncInsightsClient(
"YourApplicationID",
"YourSearchOnlyAPIKey",
client
).user("user-123456");
insights.convertedObjectIDsAfterSearch(
"book_favorite_on_search_page",
"my_online_bookshop_index",
Arrays.asList("9780545139700", "9780439785969"),
"cba8245617aeace44"
);
|
1
2
3
4
5
6
7
8
9
10
11
| client := insights.NewClient(
"YourApplicationID",
"YourSearchOnlyAPIKey",
).User("user-123456")
res, err := client.ConvertedObjectIDsAfterSearch(
"book_favorite_on_search_page",
"my_only_bookshop_index",
[]string{"9780545139700", "9780439785969"},
"cba8245617aeace44",
)
|
1
2
3
4
5
6
7
8
9
| client.execute {
send event ConvertedObjectIDsAfterSearch(
"user-123456",
"book_favorite_on_search_page",
"my_online_bookshop_index",
Seq("9780545139700", "9780439785969"),
"cba8245617aeace44"
)
}
|
You can also send conversion events only for personalization by using the same function without the “AfterSearch” suffix. See ConvertedObjectIds.
Therefore, to continue sending conversion events for personalization without impacting your conversion rate, you’ll need to do the following:
1
2
3
4
5
6
7
8
9
10
| $insights = Algolia\AlgoliaSearch\InsightsClient::create(
'YourApplicationID',
'YourSearchOnlyAPIKey'
);
$insights->user("user-123456")->convertedObjectIDs(
'book_favorite_on_search_page',
'my_online_bookshop_index',
['9780545139700']
);
|
1
2
3
4
5
6
7
8
9
10
| insights = Algolia::Insights.new(
'YourApplicationID',
'YourSearchOnlyAPIKey'
)
insights.user('user-123456').converted_object_ids(
'book_favorite_on_search_page',
'my_online_bookshop_index',
['9780545139700']
)
|
1
2
3
4
5
6
7
8
9
10
| // This requires installing the search-insights separate library:
// https://github.com/algolia/search-insights.js
// https://www.npmjs.com/package/search-insights
aa('convertedObjectIDs', {
userToken: 'user-123456',
index: 'my_online_bookshop_index',
eventName: "book_click_on_search_page',
objectIDs: ['9780545139700'],
});
|
1
2
3
4
5
6
7
| insights = client.init_insights_client().user('user-123456')
insights.converted_object_ids(
'book_favorite_on_search_page',
'my_online_bookshop_index',
['9780545139700']
)
|
1
2
3
4
5
6
7
8
9
10
11
| Insights.register(
appId: "YourApplicationID",
apiKey: "YourSearchOnlyAPIKey",
userToken: "user-123456"
)
Insights.shared?.converted(
eventName: "book_favorite_on_search_page",
indexName: "my_online_bookshop_index",
objectIDs: ["9780545139700"]
)
|
1
2
3
4
5
6
7
8
9
10
11
12
| Insights.register(
context,
"YourApplicationID",
"YourSearchOnlyAPIKey",
"user-123456"
)
Insights.shared?.converted(
"book_favorite_on_search_page",
"my_online_bookshop_index",
"cba8245617aeace44"
)
|
1
2
3
4
5
6
7
8
9
10
| var insights = new InsightsClient(
"YourApplicationID",
"YourSearchOnlyAPIKey"
).User("user-123456");
insights.ConvertedObjectIDs(
"book_favorite_on_search_page",
"my_online_bookshop_index",
new List<string> { "9780545139700" }
);
|
1
2
3
4
5
6
7
8
9
10
11
| AsyncUserInsightsClient insights = new AsyncInsightsClient(
"YourApplicationID",
"YourSearchOnlyAPIKey",
client
).user("user-123456");
insights.convertedObjectIDs(
"book_favorite_on_search_page",
"my_online_bookshop_index",
Arrays.asList("9780545139700")
);
|
1
2
3
4
5
6
7
8
9
10
| client := insights.NewClient(
"YourApplicationID",
"YourSearchOnlyAPIKey",
).User("user-123456")
res, err := client.ConvertedObjectIDs(
"book_favorite_on_search_page",
"my_only_bookshop_index",
[]string{"9780545139700"},
)
|
1
2
3
4
5
6
7
8
| client.execute {
send event ConvertedObjectIDs(
"user-123456",
"book_favorite_on_search_page",
"my_online_bookshop_index",
Seq("9780545139700")
)
}
|
When sending a conversion event, you’re not always on the search page (such as a product detail page). Therefore, you need to pass the queryID
to the detail page. We wrote a guide to show you how to use query parameters to pass the queryID
.
You can’t use search-related events in all cases. To see the difference, ask yourself, “Is this event related to my Algolia search results?” For example, “Is it a click on a search result?” or “Am I converting after searching?”. If not, then you’ll want to use our non-search-related type of events - all methods that do not have an “AfterSearch” suffix:
We’ve already discussed the first two event types in the previous section. Let’s see what you can do with the view event type.
Sending View Events
Finally, we might want to capture every product detail page that John visits. Capturing views is simpler than clicks and conversion because there is only one method: ViewedObjectIds. For example, john views the newest book on World History with the objectID 9780545139700
(this is the ISBN-13 code of the book)
In this example, we named our click event book_view_on_detail_page
.
1
2
3
4
5
6
7
8
9
10
| $insights = Algolia\AlgoliaSearch\InsightsClient::create(
'YourApplicationID',
'YourSearchOnlyAPIKey'
);
$insights->user("user-123456")->viewedObjectIDs(
'book_view_on_detail_page',
'my_online_bookshop_index',
['9780545139700']
);
|
1
2
3
4
5
6
7
8
9
10
| insights = Algolia::Insights.new(
'YourApplicationID',
'YourSearchOnlyAPIKey'
)
insights.user('user-123456').viewed_object_ids(
'book_view_on_detail_page',
'my_online_bookshop_index',
['9780545139700']
)
|
1
2
3
4
5
6
7
8
9
10
| // This requires installing the search-insights separate library
// https://github.com/algolia/search-insights.js
// https://www.npmjs.com/package/search-insights
aa('viewedObjectIDs', {
userToken: 'user-123456',
index: 'my_online_bookshop_index',
eventName: 'book_view_on_detail_page',
objectIDs: ['9780545139700'],
});
|
1
2
3
4
5
6
7
| insights = client.init_insights_client().user('user-123456')
insights.viewed_object_ids(
'book_view_on_detail_page',
'my_online_bookshop_index',
['9780545139700']
)
|
1
2
3
4
5
6
7
8
9
10
11
| Insights.register(
appId: "YourApplicationID",
apiKey: "YourSearchOnlyAPIKey",
userToken: "user-123456"
)
Insights.shared?.viewed(
eventName: "book_view_on_detail_page",
indexName: "my_online_bookshop_index",
objectIDs: ["9780545139700"]
)
|
1
2
3
4
5
6
7
8
9
10
11
12
| Insights.register(
context,
"YourApplicationID",
"YourSearchOnlyAPIKey",
"user-123456"
)
Insights.shared?.viewed(
"book_view_on_detail_page",
"my_online_bookshop_index",
"9780545139700"
)
|
1
2
3
4
5
6
7
8
9
10
| var insights = new InsightsClient(
"YourApplicationID",
"YourSearchOnlyAPIKey"
).User("user-123456");
insights.ViewedObjectIDs(
"book_view_on_detail_page",
"my_online_bookshop_index",
new List<string> { "9780545139700" }
);
|
1
2
3
4
5
6
7
8
9
10
11
| AsyncUserInsightsClient insights = new AsyncInsightsClient(
"YourApplicationID",
"YourSearchOnlyAPIKey",
client
).user("user-123456");
insights.viewedObjectIDs(
"book_view_on_detail_page",
"my_online_bookshop_index",
Arrays.asList("9780545139700")
);
|
1
2
3
4
5
6
7
8
9
10
| client := insights.NewClient(
"YourApplicationID",
"YourSearchOnlyAPIKey",
).User("user-123456")
res, err := client.ViewedObjectIDs(
"book_view_on_detail_page",
"my_only_bookshop_index",
[]string{"9780545139700"},
)
|
1
2
3
4
5
6
7
8
| client.execute {
send event ViewedObjectIDs(
"user-123456",
"book_view_on_detail_page",
"my_online_bookshop_index",
Seq("9780545139700")
)
}
|
Sending Filter Events
If you want to collect facet/filter activity, you have three methods for that.
Clicking on Facets
Here, John clicks on the “history” facet. We’ll use the ClickedFilters method with the event name book_click_on_filter
.
1
2
3
4
5
6
7
8
9
10
| $insights = Algolia\AlgoliaSearch\InsightsClient::create(
'YourApplicationID',
'YourSearchOnlyAPIKey'
);
$insights->user("user-123456")->clickFilters(
'book_click_on_filter',
'my_online_bookshop_index',
['category:history']
);
|
1
2
3
4
5
6
7
8
9
10
| insights = Algolia::Insights.new(
'YourApplicationID',
'YourSearchOnlyAPIKey'
)
insights.user('user-123456').clicked_filters(
'book_click_on_filter',
'my_online_bookshop_index',
['category:history']
)
|
1
2
3
4
5
6
7
8
9
10
| // This requires installing the search-insights separate library
// https://github.com/algolia/search-insights.js
// https://www.npmjs.com/package/search-insights
aa('clickedFilters', {
userToken: 'user-123456',
index: 'my_online_bookshop_index',
eventName: 'book_click_on_filter',
filters: [ 'category:history' ]
});
|
1
2
3
4
5
6
7
| insights = client.init_insights_client().user('user-123456')
insights.clicked_filters(
'book_click_on_filter',
'my_online_bookshop_index',
['category:history']
)
|
1
2
3
4
5
6
7
8
9
10
11
| Insights.register(
appId: "YourApplicationID",
apiKey: "YourSearchOnlyAPIKey",
userToken: "user-123456"
)
Insights.shared?.clicked(
eventName: "book_click_on_filter",
indexName: "my_online_bookshop_index",
filters: ["category:history"]
)
|
1
2
3
4
5
6
7
8
9
10
11
12
| Insights.register(
context,
"YourApplicationID",
"YourSearchOnlyAPIKey",
"user-123456"
)
Insights.shared?.clicked(
"book_click_on_filter,
"my_online_bookshop_index",
EventObjects.Filters("category:history")
)
|
1
2
3
4
5
6
7
8
9
10
| var insights = new InsightsClient(
"YourApplicationID",
"YourSearchOnlyAPIKey"
).User("user-123456");
insights.ClickedFilters(
"book_click_on_filter,
"my_online_bookshop_index",
new List<string> { "category:history" }
);
|
1
2
3
4
5
6
7
8
9
10
11
| AsyncUserInsightsClient insights = new AsyncInsightsClient(
"YourApplicationID",
"YourSearchOnlyAPIKey",
client
).user("user-123456");
insights.clickedFilters(
"book_click_on_filter,
"my_online_bookshop_index",
Collections.singletonList("category:history")
);
|
1
2
3
4
5
6
7
8
9
10
| client := insights.NewClient(
"YourApplicationID",
"YourSearchOnlyAPIKey",
).User("user-123456")
res, err := client.ClickedFilters(
"book_click_on_filter",
"my_only_bookshop_index",
[]string{"category:history"},
)
|
1
2
3
4
5
6
7
8
| client.execute {
send event ClickedFilters(
"user-123456",
"book_click_on_filter,
"my_online_bookshop_index",
Seq("category:history")
)
}
|
Viewing Facets
Here, John goes to a category page that displays history books with photos and descriptions for browsing. We’ll use the ViewedFilters method with the event name book_view_filter_page
.
1
2
3
4
5
6
7
8
9
10
| $insights = Algolia\AlgoliaSearch\InsightsClient::create(
'YourApplicationID',
'YourSearchOnlyAPIKey'
);
$insights->user("user-123456")->viewedFilters(
'book_view_filter_page',
'my_online_bookshop_index',
['category:history']
);
|
1
2
3
4
5
6
7
8
9
10
| insights = Algolia::Insights.new(
'YourApplicationID',
'YourSearchOnlyAPIKey'
)
insights.user('user-123456').viewed_filters(
'book_view_filter_page',
'my_online_bookshop_index',
['category:history']
)
|
1
2
3
4
5
6
7
8
9
10
| // This requires installing the search-insights separate library
// https://github.com/algolia/search-insights.js
// https://www.npmjs.com/package/search-insights
aa('viewedFilters', {
userToken: 'user-123456',
index: 'my_online_bookshop_index',
eventName: 'book_view_filter_page',
filters: [ 'category:history' ]
});
|
1
2
3
4
5
6
7
| insights = client.init_insights_client().user('user-123456')
insights.viewed_filters(
'book_view_filter_page',
'my_online_bookshop_index',
['category:history']
)
|
1
2
3
4
5
6
7
8
9
10
11
| Insights.register(
appId: "YourApplicationID",
apiKey: "YourSearchOnlyAPIKey",
userToken: "user-123456"
)
Insights.shared?.viewed(
eventName: "book_view_filter_page",
indexName: "my_online_bookshop_index",
filters: ["category:history"]
)
|
1
2
3
4
5
6
7
8
9
10
11
12
| Insights.register(
context,
"YourApplicationID",
"YourSearchOnlyAPIKey",
"user-123456"
)
Insights.shared?.viewed(
"book_view_filter_page",
"my_online_bookshop_index",
EventObjects.Filters("category:history")
)
|
1
2
3
4
5
6
7
8
9
10
| var insights = new InsightsClient(
"YourApplicationID",
"YourSearchOnlyAPIKey"
).User("user-123456");
insights.ViewedFilters(
"book_view_filter_page",
"my_online_bookshop_index",
new List<string> { "category:history" }
);
|
1
2
3
4
5
6
7
8
9
10
11
| AsyncUserInsightsClient insights = new AsyncInsightsClient(
"YourApplicationID",
"YourSearchOnlyAPIKey",
client
).user("user-123456");
insights.viewedFilters(
"book_view_filter_page",
"my_online_bookshop_index",
Arrays.asList("category:history")
);
|
1
2
3
4
5
6
7
8
9
10
| client := insights.NewClient(
"YourApplicationID",
"YourSearchOnlyAPIKey",
).User("user-123456")
res, err := client.ViewedFilters(
"book_view_filter_page",
"my_only_bookshop_index",
[]string{"category:history"},
)
|
1
2
3
4
5
6
7
8
| client.execute {
send event ViewedFilters(
"user-123456",
"book_view_filter_page",
"my_online_bookshop_index",
Seq("category:history)
)
}
|
Converting Facets
Here, John goes to a category page. In some personalization strategies, this is also a conversion. We’ll have to use the ConvertedFilters method with a custom the event name: book_view_conversion_filter_page
.
1
2
3
4
5
6
7
8
9
10
| $insights = Algolia\AlgoliaSearch\InsightsClient::create(
'YourApplicationID',
'YourSearchOnlyAPIKey'
);
$insights->user("user-123456")->convertedFilters(
'book_view_conversion_filter_page',
'my_online_bookshop_index',
['category:history']
);
|
1
2
3
4
5
6
7
8
9
10
| insights = Algolia::Insights.new(
'YourApplicationID',
'YourSearchOnlyAPIKey'
)
insights.user('user-123456').converted_filters(
'book_view_conversion_filter_page',
'my_online_bookshop_index',
['category:history']
)
|
1
2
3
4
5
6
7
8
9
10
| // This requires installing the search-insights separate library
// https://github.com/algolia/search-insights.js
// https://www.npmjs.com/package/search-insights
aa('convertedFilters', {
userToken: 'user-123456',
index: 'my_online_bookshop_index',
eventName: 'book_view_conversion_filter_page',
filters: [ 'category:history' ]
});
|
1
2
3
4
5
6
7
| insights = client.init_insights_client()
insights.converted_filters(
'book_view_conversion_filter_page',
'my_online_bookshop_index',
['category:history']
)
|
1
2
3
4
5
6
7
8
9
10
11
| Insights.register(
appId: "YourApplicationID",
apiKey: "YourSearchOnlyAPIKey",
userToken: "user-123456"
)
Insights.shared?.converted(
eventName: "book_view_conversion_filter_page",
indexName: "my_online_bookshop_index",
filters: ["category:history"]
)
|
1
2
3
4
5
6
7
8
9
10
11
12
| Insights.register(
context,
"YourApplicationID",
"YourSearchOnlyAPIKey",
"user-123456"
);
Insights.shared?.converted(
"book_view_conversion_filter_page",
"my_online_bookshop_index",
EventObjects.Filters("category:history")
)
|
1
2
3
4
5
6
7
8
9
10
| var insights = new InsightsClient(
"YourApplicationID",
"YourSearchOnlyAPIKey"
).User("user-123456");
insights.ConvertedFilters(
"book_view_conversion_filter_page",
"my_online_bookshop_index",
new List<string> { "category:history" }
);
|
1
2
3
4
5
6
7
8
9
10
11
12
| AsyncUserInsightsClient insights =
new AsyncInsightsClient(
"YourApplicationID",
"YourSearchOnlyAPIKey",
client
).user("user-123456");
insights.convertedFilters(
"book_view_conversion_filter_page",
"my_online_bookshop_index",
Collections.singletonList("category:history")
);
|
1
2
3
4
5
6
7
8
9
10
| client := insights.NewClient(
"YourApplicationID",
"YourSearchOnlyAPIKey",
).User("user-123456")
res, err := client.ConvertedFilters(
"book_view_conversion_filter_page",
"my_only_bookshop_index",
[]string{"category:history"},
)
|
1
2
3
4
5
6
7
8
| client.execute {
send event ConvertedFilters(
"user-123456",
"book_view_conversion_filter_page",
"my_online_bookshop_index",
Seq("filter")
)
}
|