You can send click
, conversion
, and other events that are related and unrelated to Algolia results. While events unrelated to Algolia won’t be taken into account when calculating Click and Conversion Analytics, Dynamic Re-ranking, A/B Testing, they’re useful for the Personalization and Algolia Recommend feature. Personalization can rely on user behavior on any channels to build user affinity profiles. Algolia can then use these profiles to personalize results for the individual user.
Even if you aren’t planning on implementing Personalization yet, it’s a good idea to collect these events so that you have a corpus of data ready for you when you do.
If you’re looking to send events to Algolia using the InstantSearch or integrations such as Magento, Shopify, Google Tag Manager & Segment, please refer to the guide Getting Started on Sending Events.
Insight events and implementation overview
The implementation process is slightly different for events related and unrelated to Algolia results. Both processes require you to initialize the Insights client first.
Once you initialize the Insights client, please jump to the relevant section to get started.
Initializing the Insights client
1
2
3
4
| $insights = Algolia\AlgoliaSearch\InsightsClient::create(
'YourApplicationID',
'YourSearchOnlyAPIKey'
);
|
1
| insights = Algolia::Insights::Client.create('YourApplicationID', 'YourSearchOnlyAPIKey')
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
| <!-- This requires installing the search-insights separate library: -->
<!-- https://github.com/algolia/search-insights.js -->
<!-- You can load the library by adding this snippet in the <head> of your HTML file. -->
<script>
var ALGOLIA_INSIGHTS_SRC = "https://cdn.jsdelivr.net/npm/search-insights@1.6.3";
!function(e,a,t,n,s,i,c){e.AlgoliaAnalyticsObject=s,e[s]=e[s]||function(){
(e[s].queue=e[s].queue||[]).push(arguments)},i=a.createElement(t),c=a.getElementsByTagName(t)[0],
i.async=1,i.src=n,c.parentNode.insertBefore(i,c)
}(window,document,"script",ALGOLIA_INSIGHTS_SRC,"aa");
</script>
<!-- You can also load the library using NPM. -->
<!-- https://www.npmjs.com/package/search-insights -->
<!-- Compatible with Node.js since v1.3.0 -->
|
1
2
3
4
| insights = InsightsClient.create(
'YourApplicationID',
'YourSearchOnlyAPIKey'
)
|
1
2
3
4
5
| Insights.register(
appId: "YourApplicationID",
apiKey: "YourSearchOnlyAPIKey",
userToken: "user-123456"
)
|
1
2
3
4
| val client = ClientInsights(
applicationID = ApplicationID("YourApplicationID"),
apiKey = APIKey("YourSearchOnlyAPIKey")
)
|
1
2
3
4
| var insights = new InsightsClient(
"YourApplicationID",
"YourSearchOnlyAPIKey"
);
|
1
2
3
4
| InsightsClient insights = DefaultInsightsClient.create(
"YourApplicationID",
"YourSearchOnlyAPIKey"
);
|
1
2
3
4
5
| client := insights.NewClient(
"YourApplicationID",
"YourSearchOnlyAPIKey"
)
userClient := client.User("user-123456")
|
1
| val client = new AlgoliaClient("YourApplicationID", "YourSearchOnlyAPIKey")
|
1
2
3
4
| val client = ClientInsights(
applicationID = ApplicationID("YourApplicationID"),
apiKey = APIKey("YourSearchOnlyAPIKey")
)
|
The JavaScript, iOS, and Android API clients require you to install the search-insights
library to send events. For installation instructions, please see their respective pages:
You must use an API key with the search
ACL to send events.
There are three steps after instantiating the Insights library.
1. Set clickAnalytics
and userToken
query parameters in each query
-
Set the clickAnalytics
query parameter to true
– Once you’ve enabled click analytics, each results set includes the queryID
field.
-
Set the userToken
query parameter – For query aggregation, Search Analytics, and Personalization to work properly, the analytics engine needs to uniquely identify each of your users. You need to set the userToken
parameter to tell Algolia which user is searching.
During a search
1
2
3
4
| $index->search('query', [
'clickAnalytics' => true,
'userToken' => '123456'
])
|
1
2
3
4
| index.search('query', {
clickAnalytics: true,
userToken: '123456'
})
|
1
2
3
4
5
6
| index.search('query', {
clickAnalytics: true,
userToken: '123456'
}).then(({ hits }) => {
console.log(hits);
});
|
1
2
3
4
| index.search('query', {
'clickAnalytics': True,
'userToken': '123456'
})
|
1
2
| Query query = new Query("query");
query.UserToken = "123456";
|
1
| Query query = new Query("query").setUserToken("123456").setClickAnalytics(true)
|
During client initialization
1
2
3
4
5
6
| $config = \Algolia\AlgoliaSearch\Config\SearchConfig::create('YourApplicationID', 'YourSearchOnlyAPIKey');
$config->setDefaultHeaders([
'X-Algolia-UserToken' => '123456',
]);
$client = \Algolia\AlgoliaSearch\SearchClient::createWithConfig($config);
|
1
2
3
4
| config = Algolia::Search::Config.create('YourApplicationID', 'YourSearchOnlyAPIKey')
config.default_headers['X-Algolia-UserToken'] = '123456'
client = Algolia::Search::Client.create_with_config(config)
|
1
2
3
4
5
| const client = algoliasearch('YourApplicationID', 'YourSearchOnlyAPIKey', {
headers: {
'X-Algolia-UserToken': '123456'
}
});
|
1
2
3
4
5
6
| from algoliasearch.configs import SearchConfig
config = SearchConfig('YourApplicationID', 'YourSearchOnlyAPIKey')
config.headers['X-Algolia-UserToken'] = '123456'
client = SearchClient.create_with_config(config)
|
1
| client.setHeader(withName: "X-Algolia-UserToken", to: "123456")
|
1
| client.setHeader("X-Algolia-UserToken", "123456")
|
1
2
3
4
5
6
| var configuration = new SearchConfig("YourApplicationID", "YourSearchOnlyAPIKey")
{
DefaultHeaders = new Dictionary<string, string> { { "X-Algolia-UserToken"", "123456" } }
};
var client = new SearchClient(configuration);
|
1
2
3
4
5
6
| SearchConfig configuration =
new SearchConfig.Builder("YourApplicationID", "YourSearchOnlyAPIKey")
.addExtraHeaders("X-Algolia-UserToken", "123456")
.build();
SearchClient client = DefaultSearchClient.create(configuration);
|
1
2
3
4
5
6
7
8
9
| config := search.Configuration{
AppID: "YourApplicationID",
APIKey: "YourSearchOnlyAPIKey",
Headers: map[string]string{
"X-Algolia-UserToken": "123456",
},
}
client := search.NewClientWithConfig(config)
|
1
2
3
4
5
6
7
| val client = new AlgoliaClient(
"YourApplicationID",
"YourSearchOnlyAPIKey",
customHeader = Map(
"X-Algolia-UserToken" -> "123456"
)
)
|
1
2
3
4
5
6
| val configuration = ConfigurationSearch(
applicationID = ApplicationID("YourApplicationID"),
apiKey = APIKey("YourSearchOnlyAPIKey"),
defaultHeaders = mapOf("X-Algolia-UserToken" to "123456")
)
ClientSearch(configuration)
|
If you perform the query from your back end, set the X-Forwarded-For
header to forward Algolia the user’s IP address. Please make sure to replace the IP address in the snippet with the actual IP address of your end user.
1
2
3
4
5
| $index = $client->initIndex('your_index_name');
$res = $index->search('query string', [
'X-Forwarded-For' => '94.228.178.246',
]);
|
1
2
3
4
5
6
7
8
9
10
11
12
13
| # '94.228.178.246' should be replaced with the actual IP you would like
# to search around. Depending on your stack there are multiple ways to get this
# information.
# This is only needed when you're making a request from the backend. If you make
# your request in the browser, then this is added automatically.
index = client.init_index('your_index_name')
res = index.search('query string', {
headers: {
'X-Forwarded-For': '94.228.178.246'
}
})
|
1
2
3
4
5
6
7
8
9
| const index = client.initIndex('your_index_name');
index.search('query string', {
headers: {
'X-Forwarded-For': '94.228.178.246',
},
}).then(({ hits }) => {
console.log(hits);
});
|
1
2
3
4
5
| index = client.init_index('your_index_name')
res = index.search('query string', {
'X-Forwarded-For': '94.228.178.246',
})
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| let requestOptions = RequestOptions()
let index = client.index(withName: "your_index_name")
requestOptions.headers["X-Forwarded-For"] = "94.228.178.246"
index.search(
Query(query: "query string"),
requestOptions: requestOptions,
completionHandler: { (content, error) -> Void in
if error == nil {
print("Result: \(content!)")
}
}
)
|
1
2
3
4
5
6
7
8
9
10
| RequestOptions requestOptions = new RequestOptions()
.setHeader("X-Forwarded-For", "94.228.178.246");
Index index = client.getIndex("your_index_name");
Query query = new Query("query string");
index.searchAsync(query, requestOptions, new CompletionHandler() {
@Override
public void requestCompleted(JSONObject content, AlgoliaException error) {
// [...]
}
});
|
1
2
3
4
5
6
7
8
| Index index = client.InitIndex("your_index_name");
RequestOptions requestOptions = new RequestOptions
{
Headers = new Dictionary<string,string>{ { "X-Forwarded-For", "94.228.178.246" } }
};
var result = index.Search<T>(new Query("query string"), requestOptions);
|
1
2
3
4
5
6
7
8
9
10
11
| //Sync version
index.search(
new Query("query string"),
new RequestOptions().addExtraHeader("X-Forwarded-For", "94.228.178.246")
);
//Async version
index.searchAsync(
new Query("query string"),
new RequestOptions().addExtraHeader("X-Forwarded-For", "94.228.178.246")
);
|
1
2
3
4
5
| extraHeaders := opt.ExtraHeaders(map[string]string{
"X-Forwarded-For": "94.228.178.246",
})
res, err = index.Search("query string", extraHeaders)
|
1
2
3
4
5
6
7
| client.execute {
search into "your_index_name" query Query(
query = Some("query string")
) options RequestOptions(
extraHeaders = Some(Map("X-Forwarded-For" => "94.228.178.246"))
)
}
|
1
2
3
4
5
6
7
8
| val indexName = IndexName("your_index_name")
val index = client.initIndex(indexName)
val query = Query("query string")
val requestOptions = requestOptions {
header("X-Forwarded-For", "94.228.178.246")
}
index.search(query, requestOptions)
|
Here are some examples of userToken
:
- User ID associated with an account on your system (Recommended)
- Cookie associated with an account for the user, for example, Google and Adobe Analytics
- Algolia cookie (sent by default with events)
If you’re using the JavaScript API Client, refer to the following guides on user identifiers:
If you’re sending events related and unrelated to Algolia results, please make sure that the user token is consistent for both types of events.
2. Retrieve and track the queryID
Once you’ve enabled click analytics, each results set includes the queryID
field. The queryID
is unique for every query made to Algolia. For example, Algolia returns a new queryID
each time a user appends a new character in a search-as-you-type implementation. In this user’s case:
- The first keystroke (for the character “h”) has
aef12442b87e97ac
as queryID
.
- The second key stroke (for the characters “ha”) has
cba8245617aeace44
as queryID
.
For accurate Click and Conversion Analytics, always use the latest queryID
with the API client methods. Please read the following guide about the best practice to keep track of the query ID.
You can send events one by one, as soon as they occur, or in batches. Read the guide on the best practice of sending current or older events in batches. You may also want to send historical data as events, which you can do more efficiently in batches.
Algolia-related events must occur within one hour of their search. In other words, the analytics engine only counts events related to that query if they have a timestamp
within one hour of running a query to Algolia. Events must be received by the insights API within four days of their occurrence.
For any results that come from querying Algolia’s API, there are dedicated API methods for each of these events:
1
2
3
4
5
6
7
8
9
10
11
12
| $insights = Algolia\AlgoliaSearch\InsightsClient::create(
'YourApplicationID',
'YourSearchOnlyAPIKey'
);
$insights->user("user-123456")->clickedObjectIDsAfterSearch(
'Product Clicked',
'products',
['9780545139700'],
[7],
'cba8245617aeace44'
);
|
1
2
3
4
5
6
7
8
9
| insights = Algolia::Insights::Client.create('YourApplicationID', 'YourSearchOnlyAPIKey')
insights.user('user-123456').clicked_object_ids_after_search(
'Product Clicked',
'products',
['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: 'Product Clicked',
index: 'products',
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(
'Product Clicked',
'products',
['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: "Product Clicked",
indexName: "products",
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(
"Product Clicked",
"products",
"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(
"Product Clicked",
"products",
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(
"Product Clicked",
"products",
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(
"Product Clicked",
"products",
[]string{"9780545139700"},
[]int{7},
"cba8245617aeace44",
)
|
1
2
3
4
5
6
7
8
9
10
| client.execute {
send event ClickedObjectIDsAfterSearch(
"user-123456",
"Product Clicked",
"products",
Seq("9780545139700"),
Seq(7),
"cba8245617aeace44"
)
}
|
Unlike sending click events, when sending conversion events, you don’t need to send the converted objects’ positions with it. Other than that, you send the same data as with the previous click event.
1
2
3
4
5
6
7
8
9
10
11
| $insights = Algolia\AlgoliaSearch\InsightsClient::create(
'YourApplicationID',
'YourSearchOnlyAPIKey'
);
$insights->user("user-123456")->convertedObjectIDsAfterSearch(
'Product Wishlisted',
'products',
['9780545139700', '9780439785969'],
'cba8245617aeace44'
);
|
1
2
3
4
5
6
7
8
| insights = Algolia::Insights::Client.create('YourApplicationID', 'YourSearchOnlyAPIKey')
insights.user('user-123456').converted_object_ids_after_search(
'Product Wishlisted',
'products',
['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: 'products',
eventName: 'Product Wishlisted',
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(
'Product Wishlisted',
'products',
['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: "Product Wishlisted",
indexName: "products",
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(
"Product Wishlisted",
"products",
"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(
"Product Wishlisted",
"products",
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(
"Product Wishlisted",
"products",
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(
"Product Wishlisted",
"products",
[]string{"9780545139700", "9780439785969"},
"cba8245617aeace44",
)
|
1
2
3
4
5
6
7
8
9
| client.execute {
send event ConvertedObjectIDsAfterSearch(
"user-123456",
"Product Wishlisted",
"products",
Seq("9780545139700", "9780439785969"),
"cba8245617aeace44"
)
}
|
Once you instantiate the Insight Library, you can start sending events. You can send events one by one, as soon as they occur, or in batches. Read the guide on the best practice of sending current or older events in batches. You may also want to send historical data as events, which you can do more efficiently in batches.
There are dedicated API methods for each of these events:
These methods require the same parameters as their counterparts. The only difference is that they don’t require a queryID
.
1
2
3
4
5
6
7
8
9
10
| $insights = Algolia\AlgoliaSearch\InsightsClient::create(
'YourApplicationID',
'YourSearchOnlyAPIKey'
);
$insights->user("user-123456")->viewedFilters(
'Category Page Viewed',
'products',
['category:best-sellers']
);
|
1
2
3
4
5
6
7
| insights = Algolia::Insights::Client.create('YourApplicationID', 'YourSearchOnlyAPIKey')
insights.user('user-123456').viewed_filters(
'Category Page Viewed',
'products',
['category:best-sellers']
)
|
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: 'products',
eventName: 'Category Page Viewed',
filters: [ 'category:best-sellers' ]
});
|
1
2
3
4
5
6
7
| insights = client.init_insights_client().user('user-123456')
insights.viewed_filters(
'Category Page Viewed',
'products',
['category:best-sellers']
)
|
1
2
3
4
5
6
7
8
9
10
11
| Insights.register(
appId: "YourApplicationID",
apiKey: "YourSearchOnlyAPIKey",
userToken: "user-123456"
)
Insights.shared?.viewed(
eventName: "Category Page Viewed",
indexName: "products",
filters: ["category:best-sellers"]
)
|
1
2
3
4
5
6
7
8
9
10
11
12
| Insights.register(
context,
"YourApplicationID",
"YourSearchOnlyAPIKey",
"user-123456"
)
Insights.shared?.viewed(
"Category Page Viewed",
"products",
EventObjects.Filters("category:best-sellers")
)
|
1
2
3
4
5
6
7
8
9
10
| var insights = new InsightsClient(
"YourApplicationID",
"YourSearchOnlyAPIKey"
).User("user-123456");
insights.ViewedFilters(
"Category Page Viewed",
"products",
new List<string> { "category:best-sellers" }
);
|
1
2
3
4
5
6
7
8
9
10
11
| AsyncUserInsightsClient insights = new AsyncInsightsClient(
"YourApplicationID",
"YourSearchOnlyAPIKey",
client
).user("user-123456");
insights.viewedFilters(
"Category Page Viewed",
"products",
Arrays.asList("category:best-sellers")
);
|
1
2
3
4
5
6
7
8
9
10
| client := insights.NewClient(
"YourApplicationID",
"YourSearchOnlyAPIKey",
).User("user-123456")
res, err := client.ViewedFilters(
"Category Page Viewed",
"products",
[]string{"category:best-sellers"},
)
|
1
2
3
4
5
6
7
8
| client.execute {
send event ViewedFilters(
"user-123456",
"Category Page Viewed",
"products",
Seq("category:best-sellers)
)
}
|
1
2
3
4
5
6
7
8
9
10
| $insights = Algolia\AlgoliaSearch\InsightsClient::create(
'YourApplicationID',
'YourSearchOnlyAPIKey'
);
$insights->user("user-123456")->clickedObjectIDs(
'Product Clicked',
'products',
['9780545139700']
);
|
1
2
3
4
5
6
7
| insights = Algolia::Insights::Client.create('YourApplicationID', 'YourSearchOnlyAPIKey')
insights.user('user-123456').clicked_object_ids(
'Product Clicked',
'products',
['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('clickedObjectIDs', {
userToken: 'user-123456',
index: 'products',
eventName: 'Product Clicked',
objectIDs: ['9780545139700'],
});
|
1
2
3
4
5
6
7
| insights = client.init_insights_client().user('user-123456')
insights.clicked_object_ids(
'Product Clicked',
'products',
['9780545139700']
)
|
1
2
3
4
5
6
7
8
9
10
11
| Insights.register(
appId: "YourApplicationID",
apiKey: "YourSearchOnlyAPIKey",
userToken: "user-123456"
)
Insights.shared?.clicked(
eventName: "Product Clicked",
indexName: "products",
objectIDs: ["9780545139700"]
)
|
1
2
3
4
5
6
7
8
9
10
11
12
| Insights.register(
context,
"YourApplicationID",
"YourSearchOnlyAPIKey",
"user-123456"
)
Insights.shared?.clicked(
"Product Clicked",
"products",
"cba8245617aeace44"
)
|
1
2
3
4
5
6
7
8
9
10
| var insights = new InsightsClient(
"YourApplicationID",
"YourSearchOnlyAPIKey"
).User("user-123456");
insights.ClickedObjectIDs(
"Product Clicked",
"products",
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.clickedObjectIDs(
"Product Clicked",
"products",
Arrays.asList("9780545139700")
);
|
1
2
3
4
5
6
7
8
9
10
| client := insights.NewClient(
"YourApplicationID",
"YourSearchOnlyAPIKey",
).User("user-123456")
res, err := client.ClickedObjectIDs(
"Product Clicked",
"products",
[]string{"9780545139700"},
)
|
1
2
3
4
5
6
7
8
| client.execute {
send event ClickedObjectIDs(
"user-123456",
"Product Clicked",
"products",
Seq("9780545139700")
)
}
|
1
2
3
4
5
6
7
8
9
10
| $insights = Algolia\AlgoliaSearch\InsightsClient::create(
'YourApplicationID',
'YourSearchOnlyAPIKey'
);
$insights->user("user-123456")->convertedObjectIDs(
'Product Purchased',
'products',
['9780545139700']
);
|
1
2
3
4
5
6
7
| insights = Algolia::Insights::Client.create('YourApplicationID', 'YourSearchOnlyAPIKey')
insights.user('user-123456').converted_object_ids(
'Product Purchased',
'products',
['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: 'products',
eventName: "Product Purchased',
objectIDs: ['9780545139700'],
});
|
1
2
3
4
5
6
7
| insights = client.init_insights_client().user('user-123456')
insights.converted_object_ids(
'Product Purchased',
'products',
['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: "Product Purchased",
indexName: "products",
objectIDs: ["9780545139700"]
)
|
1
2
3
4
5
6
7
8
9
10
11
12
| Insights.register(
context,
"YourApplicationID",
"YourSearchOnlyAPIKey",
"user-123456"
)
Insights.shared?.converted(
"Product Purchased",
"products",
"cba8245617aeace44"
)
|
1
2
3
4
5
6
7
8
9
10
| var insights = new InsightsClient(
"YourApplicationID",
"YourSearchOnlyAPIKey"
).User("user-123456");
insights.ConvertedObjectIDs(
"Product Purchased",
"products",
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(
"Product Purchased",
"products",
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(
"Product Purchased",
"products",
[]string{"9780545139700"},
)
|
1
2
3
4
5
6
7
8
| client.execute {
send event ConvertedObjectIDs(
"user-123456",
"Product Purchased",
"products",
Seq("9780545139700")
)
}
|