It's not possible to manually assign a user to a specific variant of an A/B test. Variant assignment is done at random and is handled automatically by Algolia.
Algolia uses the userToken sent at query time to ensure that a given user is consistently directed to the same variant throughout the duration of the test. You can’t however force a specific user into a chosen variant.
Users are identified by the userToken sent with search requests. If you’re using InstantSearch or one of our API clients, the userToken can be sent via
- the
userTokenquery parameter or, - the
X-Algolia-UserTokenrequest header.
For accurate and reliable A/B test results, it's important each user is assigned a unique userToken that is persisted between sessions. This ensures that they always see the same variant.
While users can’t be manually assigned to a specific variant, it is possible to exclude certain users from A/B tests entirely. To do so, you could set up some conditional logic to check for a certain condition such an email address and append "enableABTest":false to the search requests made by those users.
This is the same approach used for handling anonymous users, as outlined in the documentation here.