docs-site/content/guide/ab-testing.md
In the context of optimizing search experiences, A/B Testing refers to the process of testing the effect of various search and ranking parameters to empirically determine which set of options produce the most relevant results (and conversion lift) for users.
There are several A/B Testing platforms out there like:
These platforms are very good at what they do and so Typesense does not attempt to provide a built-in A/B Testing feature. Instead, in this article we'll explore how you could use any of these existing A/B Testing platforms to run search-parameter-tuning tests to fine tune Typesense.
You can run A/B tests on:
sort_by, filter_by, etc.N number of buckets or variations.Let's say we have a Books search experience and we want to determine the best query_by fields (specifically the priority order of fields) to use.
We'd first create an experiment called "Query By Priority" in our A/B Testing Platform, with the following variations:
Now when a user lands on the page, the A/B Testing platform would assign them to one of those buckets.
We'd write a conditional that looks something like this in our frontend:
const currentVariation = ABTestingLibrary.getCurrentVariation(); // Consult your A/B Testing platforms documentation for the appropriate method to use here
let queryBy = 'categories,title,author'
if(currentVariation === 'title_priority') {
queryBy = 'title,author'
} else if(currentVariation === 'author_priority') {
queryBy = 'author,title'
}
const typesenseClient = new TypesenseClient({...});
client.collections('books').documents().search({
'q': query,
'query_by': queryBy,
//...
})
Effectively, depending on the bucket the user was assigned to, we'd use a different value for query_by.
We can use a similar mechanism to switch out the collection name to test overrides and synonyms, or other search parameters.
To track results, we'd instrument our search results page to send click-events to our A/B Testing platform, along with other standard conversion events like purchases.
The A/B Testing platform should then aggregate results across all variations and show you which variation performed the best based on your objective.
<meta name="docsearch:version" content="1.0.0" />