Insights
Clicked Object IDs After Search |
Send a click event to capture a query and its clicked items and positions. |
Clicked Object IDs |
Send a click event to capture clicked items. |
Clicked Filters |
Send a click event to capture the filters a user clicks on. You can’t send these events for numeric filters. |
Converted Object IDs After Search |
Send a conversion event to capture a query and its clicked items. |
Converted Object IDs |
Send a conversion event to capture clicked items. |
Converted Filters |
Send a conversion event to capture the filters a user uses when converting. |
Viewed Object IDs |
Send a view event to capture viewed items. |
Viewed Filters |
A user browsing on a category page usually sees content filtered on that specific category. However, they haven’t clicked on or interacted with that filter. In scenarios where a user sees filtered content without interacting with that filter, you send view events. Sending a view event captures the filters a user sees when viewing filtered content without having actively filtered it. |
Send Events |
Send a batch of events. |
It’s recommended to use the Kotlin API client, which is better suited for Android development.
The Insights API lets you capture click, conversion, and view events to help you understand how your users interact with your digital experience.
We released a new version of the JavaScript API client in public beta. Read the beta documentation for more information.
We released a new version of the PHP API client in public beta. Read the beta documentation for more information.
We released a new version of the Java API client in public beta. Read the beta documentation for more information.
Install the Insights client
The Insights client is distributed as a separate npm package. You can find the source code on GitHub
To send Insights events from your JavaScript application, you can include a code snippet directly in your HTML or install it as a dependency in your project.
Include the Insights client in your HTML
Paste the following code snippet into the <head>
tag of every page where you want to track Insights events.
1
2
3
4
5
6
7
8
<script>
var ALGOLIA_INSIGHTS_SRC = "https://cdn.jsdelivr.net/npm/search-insights@2.2.1";
!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>
Install the Insights client with npm
Install the search-insights
package in your project:
1
npm install search-insights
Initialize the Insights client
To initialize the Insights client, you need your Algolia application ID and your API key with search
permissions.
You can find both in your Algolia dashboard.
1
2
3
4
5
6
7
8
9
10
<?php
# Installation instructions:
# https://www.algolia.com/doc/api-client/getting-started/install/
require_once __DIR__."/vendor/autoload.php";
use Algolia\AlgoliaSearch\InsightsClient;
$insightsClient = InsightsClient::create(
"YourApplicationID",
"YourSearchOnlyAPIKey"
)
Identify users
You need to provide anonymous or pseudonymous user identifiers as userToken
when tracking Insights events. To identify users consistently, you should provide your own user IDs:
1
2
// See previous code snippet for how to initialize the Insights client
aa('set-user-token', 'user-token-1')
The search-insights
library can also generate anonymous user IDs that it stores in a cookie.
1
2
3
4
5
6
7
const aa = require('search-insights')
aa('init', {
appId: 'YourApplicationID',
apiKey: 'YourSearchOnlyAPIKey',
+ useCookie: true,
})
Make sure to obtain user consent before storing cookies on a user’s device.