Skip to main content
Events are actions that users take on your app or website. They unlock powerful features, such as recommendations, personalization, smarter search results, and analytics that help you optimize your user experience. For more information, see Choose how to send events. To send events from your InstantSearch Android app, follow these steps:
  1. Add the insights client.
  2. Add click events when users click search results.
  3. Track conversions that start in your InstantSearch app.

Add the InstantSearch Insights library

Add the library as a dependency to your build.gradle file:
Gradle

Add the Insights client

To add the Insights client, you’ll need your Algolia application ID, (search) API key, and the name. You can find your application ID and API key in the Algolia dashboard.
Kotlin
To send events without timestamps, and be automatically attributed on the server, set the generateTimestamps parameter to false:
Kotlin

Set the user token

All events must have a to specify the user it relates to. You can set it in three ways:
  • Globally, for all events
  • Per app, for every event tracked by the app
  • Individually, for each event
Kotlin

User opt-out

You can exclude users who opted out from tracking with the following code:
Kotlin

Enable automatic view events tracking

InstantSearch can automatically send view events when hits are returned from Algolia. To enable this feature, set isAutoSendingHitsViewEvents to true when you initialize HitsSearcher:
Kotlin

Create a HitsTracker to track events from search results

Kotlin

Create a FilterTracker to track events from filters

Kotlin

Send events

Use the trackView, trackClick, and trackConversion methods to send events. When you add events, check them in the Events Debugger in the Algolia dashboard. For more information, see Validate your events.

Send view events

Kotlin

Send click events

Kotlin

Send conversion events

Kotlin
If you upgraded from InstantSearch Android 3.x to 4.x:
  • Your hit model must include an objectID and implement the Indexable interface.
  • Facet results are now FacetHits (they used to be Facet).
Conversions often happen outside your search pages. For example, the Order completed event for a successful purchase happens in the shopping cart. To capture these conversions, keep track of the query ID across your app.

Event batching

By default, events are sent in batches of 10. To customize this, adjust the minBatchSize parameter:
Kotlin

Enable logging

You can also check if you’ve sent an event by enabling logging:
Kotlin
After you’ve enabled it, check the output for success messages or errors.
For the positions parameter of the clickedObjectIdsAfterSearch method, the first object in the list of search results has a value of 1 (not 0), the second has a value of 2.
Last modified on July 10, 2026