Skip to main content

Server-side A/B testing

Last updated on Nov 24, 20262 min read

In short​

With server-side A/B testing, your server decides which variation a visitor sees and renders it before the page is delivered. No client-side JavaScript changes the page, so there is no flicker. It also works where a classic client-side snippet does not: headless setups, server-side rendered applications and native mobile apps.

The experiment itself, with its traffic distribution, start and stop, is managed in the Varify dashboard as usual.

Create a server-side experiment​

The Varify dashboard with the dialog „New Experiment“: experiment type Server-Side is selected, an experiment name is entered, and the button „Create Experiment“ is below
  1. In the Varify dashboard, click Create new Experiment.
  2. Under Experiment Type, select Server-Side.
  3. Enter an Experiment Name and click Create Experiment.
  4. The experiment now appears in your experiment list. There you set the traffic distribution and start the experiment.
  5. Note the Experiment ID and the Variation IDs of the experiment. Your code needs them to render the right variation.

Choose your integration​

Your setupUse
Next.js with the App Router@varify-io/nextjs
Another JavaScript or TypeScript backend or framework@varify-io/core
Another language or frameworkRequest an SDK
An existing Delivery API integrationDelivery API (legacy). It still works unchanged.

Installation, setup, API and options of both SDKs are documented on their npm pages.

How the SDKs work​

  1. Your server loads the experiment configuration of your team.
  2. The SDK assigns the visitor to a variation locally, without a network call per visitor. The assignment is deterministic and stored in a cookie, so the visitor keeps their variation on later requests.
  3. Your server renders the variation.
  4. varify.js on the page receives the tracking event and delivers it to your tracking provider, while considering the visitor's consent. varify.js must therefore be on the page. Without tracking, the dashboard shows the experiment configuration but no evaluation data.

If the configuration cannot be loaded in time, every experiment shows the original and your pages keep working.

Another language or framework​

The SDKs cover JavaScript and TypeScript today. If you work with another stack, for example:

  • Python (Django, Flask, FastAPI)
  • PHP (Laravel, Symfony)
  • Ruby (Rails)
  • Java or Kotlin (Spring)
  • Go
  • .NET
  • iOS (Swift) or Android (Kotlin)

send a short request to [email protected]. Tell us your language and framework, and how your application renders pages. This helps us to decide which SDK to build next.

Until then, you can integrate with the Delivery API (legacy). It is a REST interface and works from any language.

Developer documentation​