Which Events Should I Collect?
On this page
What is an Event?
Every insight and analytics metric is based on the same information: an event that is tied to a user action. For any insight or analytic feature to work - whether it be to track click behavior or create user preferences or perform A/B testing - you always need to do the same thing: collect an event.
For every distinct event, there is always a single line of code that asks for information relevant to the goal you want to achieve. A quick example is click analytics: you need to send Algolia the click details, namely, which search created the results, which item the user clicked on, and in what position in the result list. For user preferences, it’s almost the same, but you’ll need to add a user identification along with some other relevant information that helps give the preference some context.
So the main concerns regarding event capturing is where you place the code and what parameters you send to Algolia.
Using Events to capture user behavior and preferences
To make all that possible, Algolia has set up an event-capturing mechanism that allows you to collect user behavior. Event capturing is flexible, and each one has its own unique context.
For example, some events are meaningful only within the context of a search.
- which items users click on,
- what filters they use,
- and where they go after searching.
Some events can be product-related, meaning that you can track the users preferences for certain products.
- what brands they prefer,
- what colors and other such category-based data they favor,
- and what specific items they prefer or buy.
Thus, Algolia needs to collect different kinds of events to achieve one or more of these goals. For example, if you want to know the most popular words that your users are typing, Algolia needs to store every query. If you want to know how many results a query generates, Algolia needs to store the count of records in every result set, along with the query string that generated the results. And if you want to know which items users click on, and in what position, you need to send that too.
Gathering User Events Through Insights
Insights events (click, conversion, view) used for analytics and/or personalization do not take immediate effect. The delay can range from 10 to 60 minutes depending on how long after the search they are sent. For precise times, see our page on when Insights events take effect.
There are 2 kinds of events to capture:
1- Capturing actions on an item
Action-based events include bookmarking an item, viewing a product page, putting a product on a wish list or shopping cart, buying a product, reading an article, and many other events that you consider useful in defining user preferences. For this to work, you need to make sure that these events are captured every time they occur.
Here’s what you need to send:
- The user
- The event type of the action
- The action taken by the user
- The item on which the action was taken
2- Capturing actions on categories (facets)
You can send events related not only to a particular item but to a group of items, identified by a filter. For this, you send the filter along with its associated action. For example, if a user visits the category page “Electronics” of an e-commerce website, it could be interesting to capture this as a filter event, to boost this category as an insight.
Here’s what you need to send:
- The user
- The event type
- the action taken
- The filter you consider relevant to the action taken
Note: For this to work, the filter has to be set up as an attribute for faceting.
Facet events don’t have to be linked to the selection of a facet in the UX. One scenario is when sending a campaign targeting a specific brand or product type. If a user clicks on the campaign, the customer could send a facet event with the brand “Apple” or product type “tablet”.
To conclude, you should send user actions that you consider relevant to building an understanding of your user’s preferences. These events can be either their interactions with the items in your index, or with a group of items identified by a filter.
Calculating click-through and conversion rates
We don’t differentiate between different types of click and conversion events when calculating click-through-rate and conversion rate, respectively. In other words, we only calculate one overall click-through-rate for all click events following a search and one overall conversion rate for all conversion events following a search.
For example, if you send click events when a user clicks an article and when a user clicks an ad, we calculate click-through-rate as the percentage of searches which resulted in any kind of click. Similarly, if you send conversion events when a user bookmarks a product and when a user adds a product to their cart, the conversion rate reflects the number of searches in which either of these happened. We don’t provide separate conversion rates for bookmarking products versus adding products to the cart.
Though we treat all types of click and conversion events the same when calculating click-through-rate and conversion rate, you can weigh distinct types of click and conversion events differently for personalization purposes.
For a click or conversion event to count towards click-through-rate and conversion rate, you must include the
queryID as part of the event payload. For more information, please see our FAQ on why some click events are not used for click analytics.
Examples of events worth tracking
Each event is paired with a suggested name. You should use these suggested names and follow our naming guidelines for custom events.
E-commerce event examples
For E-commerce applications, consider tracking some of the following events:
Product Viewed: A user viewed a product page.
Landing Page Viewed: A user viewed a landing page.
Product Clicked: A user clicked on a item on the home page.
Product Clicked: A user clicked on a item on a category page.
Product Clicked: A user clicked on a item on a newsletter email.
Search Result Clicked: A user clicked on a search result.
Filter Clicked: A user clicked on a filter.
Menu Clicked: A user clicked on a menu item.
Product Bookmarked: A user bookmarked a product.
Product Liked: A user liked a product.
Product Recommended: A user recommended a product.
Product Added to Cart: A user added a product to their cart.
Product Purchased: A user purchased a product.
Media event examples
For a Media application, consider tracking some of the following events:
Article Clicked: A user clicked on an article.
Ad Clicked: A user clicked on an ad.
Article Bookmarked: A user bookmarked an article.
Article Liked: A user liked an article.
Article Recommended: A user recommended an article
Video Watched: A user watched a video.
Article Read: A user read an article.
Playlist Followed: A user followed a playlist.
Author Followed: A user followed an author.
Brand Followed: A user followed a brand.
List of objects
Also, each of the events related to an object also accepts a list of objects. For example, it is possible to send a “purchase” event containing the list of objects that were purchased together.