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.
- Open your project → Experiments → New Experiment
- Choose Server-side Test
- Give the experiment a name and set up your variants (
Variant 1,Variant 2, …) - Configure your primary goal (click, event, revenue, etc.)
- 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
- Node.js
- Python
- PHP
- Ruby
npm install mida-node
pip install mida-python
composer require mida-so/mida-php
gem install mida-ruby
Step 3 — Initialize the client
Pass your Project key once when your application starts.
- Node.js
- Python
- PHP
- Ruby
const Mida = require('mida-node');
const mida = new Mida('YOUR_PROJECT_KEY');
from mida import Mida
mida = Mida('YOUR_PROJECT_KEY')
require 'vendor/autoload.php';
use Mida\Mida;
$mida = new Mida('YOUR_PROJECT_KEY');
require 'mida'
mida = Mida.new('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).
- Node.js
- Python
- PHP
- Ruby
const variant = await mida.getExperiment('YOUR_EXPERIMENT_KEY', userId);
if (variant === 'Control') {
// Original experience — nothing changes
} else if (variant === 'Variant 1') {
// Treatment experience
}
variant = mida.get_experiment('YOUR_EXPERIMENT_KEY', user_id)
if variant == 'Control':
pass # Original experience
elif variant == 'Variant 1':
pass # Treatment experience
$variant = $mida->getExperiment('YOUR_EXPERIMENT_KEY', $userId);
if ($variant === 'Control') {
// Original experience
} elseif ($variant === 'Variant 1') {
// Treatment experience
}
variant = mida.get_experiment('YOUR_EXPERIMENT_KEY', user_id)
case variant
when 'Control'
# Original experience
when 'Variant 1'
# Treatment experience
end
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.
- Node.js
- Python
- PHP
- Ruby
// Custom event
await mida.setEvent('signup_completed', userId);
// Revenue / purchase
await mida.setEvent('Purchase', userId, {
revenue: 49.99,
quantity: 1,
currency: 'USD'
});
# Custom event
mida.set_event('signup_completed', user_id)
# Revenue / purchase
mida.set_event('Purchase', user_id, {
'revenue': 49.99,
'quantity': 1,
'currency': 'USD'
})
// Custom event
$mida->setEvent('signup_completed', $userId);
// Revenue / purchase
$mida->setEvent('Purchase', $userId, [
'revenue' => 49.99,
'quantity' => 1,
'currency' => 'USD'
]);
# Custom event
mida.set_event('signup_completed', user_id)
# Revenue / purchase
mida.set_event('Purchase', user_id, { 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
- SDK catalog → — full list of supported languages with install commands and GitHub links
- Server-side overview → — how bucketing, variant names, and goal tracking work
- Get Experiment Result → — full result response schema