Skip to main content

Client-side Quickstart

This quickstart is for client-side (website) experiments

Mida runs variant CSS and JavaScript in the visitor's browser via the Mida script. If you want to run experiments in your backend, mobile app, or API, see the Server-side Quickstart and SDK catalog instead.

This guide walks you through the full experiment lifecycle using the Mida API: create a draft, launch it, read results, and stop it when you are done. Copy-paste the curl commands and replace the placeholder values.

You'll need:

  • Your Project Key — from Dashboard → Settings → API
  • Your API Key — from Dashboard → Settings → API Keys
  • Your regionus or eu

Step 1 — Create the experiment

Create an experiment in status 9 (draft). The experiment is saved but not yet running.

curl --request POST \
--url "https://api-{region}.mida.so/v2/project/YOUR_PROJECT_KEY/create-experiment" \
--header "Authorization: Bearer YOUR_GENERATED_API_KEY" \
--header "Content-Type: application/json" \
--data '{
"test_name": "Homepage CTA Button Color Test",
"url": "https://example.com/",
"variants": [
{
"name": "Variant 1",
"nickname": "Red CTA Button",
"customCSS": ".cta-button { background-color: #FF5733 !important; color: #fff !important; }",
"customJS": "",
"data": []
}
],
"primary_goal": {
"goal_name": "CTA Button Click",
"goal_type": "clickOnElement",
"goal_value": ".cta-button"
},
"configuration": {
"traffic_allocation": 100,
"confidence_interval": 95
}
}'

Response:

{
"success": true,
"status": 9,
"test_id": 28222,
"company_id": 1001,
"goal_profile_id": 8936,
"secondary_goals_count": 0,
"warnings": []
}

Save the test_id — you'll use it in every subsequent step.

Variants explained
  • Do not include Control in variants. The original page is added automatically.
  • Treatment variant names must be exact: Variant 1, Variant 2, and so on. Use nickname for human-friendly labels like "Red CTA Button".
  • Use customCSS and/or customJS for code-based changes. Keep data: [] unless you are sending visual-editor DOM changes.

Step 2 — Launch the experiment

Set status to 1 (live) to begin splitting traffic between variants.

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

Response:

{
"success": true,
"test_id": 28222,
"status": 1
}

The experiment is now live. Visitors to the test URL will be split between Control and your variant.


Step 3 — Check results

After visitors have arrived and conversions have been tracked, retrieve per-variant results:

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

Response:

{
"success": true,
"test_id": 28222,
"test_name": "Homepage CTA Button Color Test",
"status": 1,
"days_running": 7,
"total_visitors": 2980,
"total_conversions": 268,
"variants": [
{
"variant_id": "0",
"name": "Control",
"visitors": 1500,
"conversions": 120,
"conversion_rate": 8.0,
"is_control": true
},
{
"variant_id": "1",
"name": "Variant 1",
"nickname": "Red CTA Button",
"visitors": 1480,
"conversions": 148,
"conversion_rate": 10.0,
"improvement": 25.0,
"is_control": false
}
]
}

The improvement field shows relative lift vs the control. Here, Variant 1 converts 25% better than Control.


Step 4 — Deactivate the experiment

When you have a winner, deactivate the experiment with status 0:

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

Setting status 0 stops data collection but preserves all results. You can restart the experiment at any time by setting status back to 1.


Common patterns

Filter results by date range

curl "https://api-{region}.mida.so/v2/project/YOUR_PROJECT_KEY/experiment/28222/result?start_date=2024-01-15&end_date=2024-02-15" \
-H "Authorization: Bearer YOUR_GENERATED_API_KEY"

Create experiment with a pre-existing goal

If you've already created a goal and have its key, reference it directly:

--data '{
"test_name": "Pricing Page Headline Test",
"url": "https://example.com/pricing",
"variants": [
{
"name": "Variant 1",
"nickname": "Larger headline",
"customCSS": "h1 { font-size: 2.5rem; }",
"data": []
}
],
"primary_goal_key": "cta_button_click"
}'

Preview before launch

Use the Preview URLs endpoint to generate QA links for Control and each treatment. The preview URL format is:

https://example.com/?test-preview=28222&test-variant=Variant_1

Control uses test-variant=0. Treatment variants use their fixed name with spaces replaced by underscores, such as Variant_1 or Variant_12.

Create experiment and launch immediately

Pass "status": 1 in the create request to skip the draft step:

--data '{
"test_name": "Homepage Hero Test",
"status": 1,
"url": "https://example.com/",
"variants": [...]
}'

Prevent duplicate experiments (idempotency)

Pass a unique idempotency_key to safely retry without creating duplicates. Same key returns the original response for 24 hours:

--data '{
...
"idempotency_key": "deploy-2026-04-01-homepage-cta"
}'

Status codes reference

CodeMeaning
9Draft — saved, not running
1Live — actively running
0Inactive — stopped, data preserved, can be restarted

Goal types reference

When setting a primary_goal inline, use one of these goal_type values:

goal_typeWhat it tracksgoal_value example
clickOnElementClick on a CSS selector.buy-btn
clickOnTextClick on an element with matching textAdd to cart
formSubmitForm submissionform#signup
pageviewURL partial match/thank-you
pageviewExactExact URL matchhttps://example.com/thank-you
pageviewWildcardURL with * wildcards/products/*/confirm
pageviewRegexRegex URL pattern^/checkout/.+/success$
eventCustom event namesignup_completed
revenuePurchase or order eventPurchase
scriptManual trigger identifierpurchase_complete

What's next