The search-as-a-service platform, Algolia, provides out-of-the-box analytics for A/B testing, offering insight into conversions, click-through rates, and the average click position. But, you often need to visualize this search data in other tools to gain more information on average cart size, customer context, user behavior, and so on.
In this recipe, you’ll learn how to pipe Algolia’s A/B test data to your data warehouses and analytics tools to measure different test metrics and run further analysis.
Note: while this recipe is focused on retail and e-commerce, it can be applied to any industry.
This guide will teach you how to expose the variant test ID and test number from the Algolia response (either through the API client or InstantSearch React library) and pass that information as a property to your track calls.
(This recipe assumes you’ve already set up Algolia analytics tracking through Segment – here’s how.)
Algolia’s getRankingInfo parameter provides more detailed information about the search request in the search response payload. It exposes deeper contextual information, like details about the ranking formula as well as the abTestID and abTestVariantID.
abTestID (integer): In case of A/B testing, returns the ID of the A/B test.
abTestVariantID (integer): In case of A/B testing, returns the ID of the variant used. The variant ID is the position in the array of variants (starting at 1).
When an A/B test is enabled on the Algolia index, these two properties will be visible on any search to that index when getRankingInfo:true. Algolia will lock that specific user into the variant test group for the duration of the A/B test based on the user’s IP or userToken (if provided).
The IP and userToken will not persist across sessions or devices, and is subject to how the Algolia implementation was conducted. For that reason, it may be prudent to only pass the test variant through track calls rather than identify calls (as the latter would assume the user is permanently part of the test variant across sessions and devices).
There are a few ways to turn on getRankingInfo in Algolia, but the simplest, low-code approach is to leverage Algolia’s Rules feature.
Using Rules:
- Enter the Rules interface to add a new manual rule. (Make sure you’re on the index that you’ll be running the A/B test on.)
- Select the trash can icon in the top right corner to remove the condition. This will create a condition-less rule that will be applied across all searches to that index.