Skip to main content

Server-side Quickstart

This guide walks you through running your first server-side A/B experiment with Mida. The example uses Node.js, but the same steps apply to every SDK — only the installation command and syntax differ.

You'll need:

  • A Mida account with an active project
  • The Project key from Dashboard → Settings → API
  • Node.js installed (or your preferred language — see SDK catalog)

Step 1 — Create a server-side experiment in the dashboard

Server-side experiments are created in the Mida dashboard, not via the REST API.

  1. Open your project → Experiments → New Experiment
  2. Choose Server-side Test
  3. Give the experiment a name and set up your variants (Variant 1, Variant 2, …)
  4. Configure your primary goal (click, event, revenue, etc.)
  5. Save as draft — do not launch yet

The dashboard will generate an Experiment key (e.g. homepage-pricing-v2). Copy it — you'll use it in your code.


Step 2 — Install the SDK

npm install mida-node

Step 3 — Initialize the client

Pass your Project key once when your application starts.

const Mida = require('mida-node');
const mida = new Mida('YOUR_PROJECT_KEY');

Step 4 — Get the variant assignment

Call getExperiment() on each request, passing the Experiment key and a distinct user ID (any stable string that uniquely identifies the user — a database ID, session ID, or anonymous UUID all work).

const variant = await mida.getExperiment('YOUR_EXPERIMENT_KEY', userId);

if (variant === 'Control') {
// Original experience — nothing changes
} else if (variant === 'Variant 1') {
// Treatment experience
}
Variant names are fixed

Always use the exact strings Control, Variant 1, Variant 2, etc. These match what you configured in the dashboard and cannot be renamed in your code.


Step 5 — Track conversions

Call setEvent() whenever a conversion happens for the user. The event name must match the goal you set up in the dashboard.

// Custom event
await mida.setEvent('signup_completed', userId);

// Revenue / purchase
await mida.setEvent('Purchase', userId, {
revenue: 49.99,
quantity: 1,
currency: 'USD'
});

Step 6 — Launch the experiment

Go back to the dashboard, open the experiment, and set its status to Live. Traffic will start splitting immediately.

You can also launch via the REST API:

curl --request PATCH \
--url "https://api-{region}.mida.so/v2/project/YOUR_PROJECT_KEY/experiment/TEST_ID/status" \
--header "Authorization: Bearer YOUR_GENERATED_API_KEY" \
--header "Content-Type: application/json" \
--data '{"status": 1}'

Step 7 — Read results

Results appear in the Mida dashboard under your experiment. You can also fetch them via the REST API:

curl "https://api-{region}.mida.so/v2/project/YOUR_PROJECT_KEY/experiment/TEST_ID/result" \
-H "Authorization: Bearer YOUR_GENERATED_API_KEY"

What's next