Guides / Sending events / Implementing events / Best practices

You can collect user behavior in the form of events. You can send events to Algolia’s Insights API which enables calculating Advanced Analytics, A/B testing, Dynamic Re-Ranking, Personalization, and Recommend.

Different events make use of different properties. For some events, you need to perform additional actions before sending them, for example, obtaining the queryID. To make the most out of your user events, follow these best practices when implementing events.

You can find best practices for handling the queryID and userToken parameters in separate guides.

Naming events

All events must have an eventName property. The name can be up to 64 ASCII characters. To maintain a clean data set and maximize the impact of your user events data, you need to establish a clear naming convention. If you use multiple analytics services next to Algolia Analytics, it’s essential to name events consistently to facilitate analytics aggregation.

Algolia recommends the following practices:

  • Use Segment’s object-action framework to name events according to the object users interact with and the interaction type—for example “Product Added to Cart”. If a user action can occur on multiple pages, you can distinguish these events by adding the page type to the event name. For example, to distinguish if the product was added from a product-listing page or a product-detail page you can add: “PDP;Product Added to Cart” and “PLP;Product Added to Cart”
  • Choose non-technical event names so that every team member can understand and use them
  • Capitalize your event names consistently, for example using title case

Including the correct indexName

All events need to include the name of the targeted Algolia index. For example, if a user clicks or converts on a search result, the indexName is the index’s name where the result comes from. If a user views a filter, the indexName is where you’ve declared the filter attribute in the attributesForFaceting.

Including objectIDs for item-based events

If an event occurs on a specific item or set of items (instead of a category of items), you need to include the items’ objectIDs. You can send up to 20 objectIDs in one call.

Click events related to searching and browsing require the positions parameter. This parameter specifies the clicked items’ positions in the results set. For example, if a user clicks the second and then fourth result, the positions parameter would be [2, 4]. Algolia uses this parameter to calculate the average click position.

Sending multiple types of events

Algolia encourages you to send as many different click and conversion events as reflect meaningful user behavior. For example, you could send conversion events for both wishlisting a product and buying it.

However, Algolia only calculates one overall click-through-rate for all click events following a search and one overall conversion rate for all conversion events following a search. If you’re sending multiple types of clicks or conversions, it’s important to keep this in mind when looking at click-through and conversion rates. These rates represent the percentage of searches that resulted in any clicks or conversion, respectively.

For example, suppose a user searches for “ps5”, then buys it. This counts as a converted search. Suppose another user searches for “ps5”, then adds it to their wishlist, then buys it. This is also a converted search. It doesn’t count any differently towards the conversion rate because the user engaged in two conversion behaviors on the same search.

Validating events

When first sending events, you should validate that Algolia is receiving the events as you expect. The guide on validating events outline the tools and methods you can use.

Did you find this page helpful?