Skip to Content
iAdvizeDocs

Start a widget experiment

Starts an A/B test of two saved widget versions, arm A (a version of the widget in the path) and arm B (a version of the same widget or, with `widgetId`, of another widget of the site on the same pages). Neither has to be the live version, and a version tested before can be used again. Each session is assigned to one arm at its first eligible page view, 50/50, and keeps it. The floor of sessions per arm is set by the system and the split is fixed, so the body names the two arms and, when needed, what you confirm. Both versions can no longer change once it starts. The start can take other live widgets on an arm's mount slot offline and replaces the live version of an arm's widget for the test's sessions: call `POST /experiments/preview` first and send what it names in `confirm`. Refused with `widget_experiment_refused` when it cannot start: its `reason` is `same_arm` (the two arms are the same version), `widget_held` (a widget is already in a running test), `no_page_type` (a version shows on no page type), `targeting_mismatch` (the arms target different pages or hold different page rules: same page types on every device, desktop and mobile, and the same rules by products and collections, in any order), `perimeter_overlap` (another test runs on some of the same pages), `holdout_running` (a holdout runs on the site) or `confirmation_required` (the start would take live widgets offline or replace live versions and `confirm` does not cover them: the problem carries a `confirmation` member with what to send back). A widget or version that is not in the site is a `404`. Records an audit entry (`engagement_widget.experiment_started`) attributed to the API key.

POST
/api/v1/sites/{siteId}/engagement-widgets/{widgetId}/experiments

Authorization

ApiKeyAuth
headerAuthorizationBearer <token>

A WorkOS org-scoped API key, created from the dashboard's organization settings page. Identifies the tenant every read and write is scoped to. Missing, malformed, unknown, revoked, expired, or non-organization-owned keys all return 401 (no distinction, so the response can't be used to probe which keys or org ids exist).

Path Parameters

siteId*string

The site id (prefixed site_). A site id that isn't yours is a 404, same as any other cross-tenant id.

widgetId*string

The widget id (prefixed ewgt_). For an experiment it may be the widget of either arm.

Request Body

application/json
  1. body

The split (50/50) and the floor are not inputs: a body that names anything else is refused with 400.

arms*array<>

The two arms, [arm A, arm B]. They must be two different versions.

Items2 <= items <= 2
confirm?

What you accept the start to change. Optional when the preview says no confirmation is required; the start is refused with confirmation_required unless it covers everything the start would change.

Response Body

The experiment that just started.

application/json
  1. response
data*

A widget A/B test with its per-arm counts and verdict.

Example Request
curl -X POST 'https://example.com/api/v1/sites/string/engagement-widgets/string/experiments' \  -H 'Content-Type: application/json' \  -d '{  "arms": [    {      "versionId": "ewgv_01kvnwmagvf27rc9cze5rm9e1r"    },    {      "widgetId": "ewgt_01kvnwmagwf27rc9d7zef4qksf",      "versionId": "ewgv_01kvnwmagwf27rc9d7zef4qksf"    }  ],  "confirm": {    "offlineWidgetIds": [],    "displacedLiveVersions": true  }}'
Example Response
{  "data": {    "id": "ewxp_01kvnwmagvf27rc9cze5rm9e1r",    "status": "running",    "endedReason": null,    "startedAt": "2026-11-02T09:30:00.000Z",    "endedAt": null,    "floorPerArm": 2400,    "splitPercent": 50,    "arms": [      {        "arm": "a",        "widgetId": "ewgt_01kvnwmagvf27rc9cze5rm9e1r",        "versionId": "ewgv_01kvnwmagvf27rc9cze5rm9e1r",        "assignedSessions": 0,        "startedSessions": 0,        "startRate": null      },      {        "arm": "b",        "widgetId": "ewgt_01kvnwmagwf27rc9d7zef4qksf",        "versionId": "ewgv_01kvnwmagwf27rc9d7zef4qksf",        "assignedSessions": 0,        "startedSessions": 0,        "startRate": null      }    ],    "verdict": {      "state": "below_floor",      "winner": null    }  }}