search
Use this event to track when users click items in the search results.
If youβre using Algolia to build your category pages,
youβll also use the clickedObjectIDsAfterSearch
event.
For details where this event is used, see Event types.
Related methods:
clickedObjectIDs
: track click events not related to Algolia requests.sendEvents
: if you donβt want to send real-time events.
Examples
The following example sends one click event to the Algolia Insights API. The event represents a useruser-123456
clicking on the item objectID-1
,
which is at the second position in the results from the index your_index_name
For more information about initializing the JavaScript Insights client aa
,
see Initialize the Insights client.
JavaScript
Parameters
Name of the specific event.Format: 1-64 ASCII characters, except control characters.To maximize the impact of your events,
use consistent event names and consistent formatting,
for example, βProduct Added To Cartβ (always in title case).For example, you can adopt Twilio Segmentβs object-action framework.
Name of the Algolia index.Format: same as the index name used by the search engine.Some API clients use
index
instead of indexName
.List of object IDs for records of an Algolia index.You can include up to 20 object IDs.
Positions of the clicked results in the search results.
This property is required for click events with
queryID
.
The first search result has a position of 1 (not 0).You must provide one position
for each object ID.Algolia uses this parameter to calculate the average click position.The position is absolute, and not relative, to any results page.
For example, if there are 10 results per page,
the position of the third record of the second results page is 13.
Since page
starts at 0,
you can use the following formula: positionOnPage + page * hitsPerPage
.Unique identifier for a search query.A
queryID
is required for events related to search or browse requests.If you add clickAnalytics: true
as a search request parameter,
the queryID
is included in the API response.See also: Keep track of query IDsAnonymous user identifier.See also: User token
Pseudonymous identifier for authenticated users.See also: User token
Donβt include personally identifiable information in user tokens.