Skip to Content
iAdvizeDocs

Preview a widget experiment start

A dry run of the start: takes the start body without `confirm` and answers which live widgets the start would take offline and which live versions it would replace, so you can send them back as `confirm`. Nothing is written and no audit entry is recorded. Every other refusal of the start (`widget_experiment_refused`, with its closed `reason`, or a `404` for a widget or version that is not in the site) is answered as the start would answer it.

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

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

Response Body

What the start would change.

application/json
  1. response
data*

What a start would change, with nothing written.

Example Request
curl -X POST 'https://example.com/api/v1/sites/string/engagement-widgets/string/experiments/preview' \  -H 'Content-Type: application/json' \  -d '{  "arms": [    {      "versionId": "ewgv_01kvnwmagvf27rc9cze5rm9e1r"    },    {      "widgetId": "ewgt_01kvnwmagwf27rc9d7zef4qksf",      "versionId": "ewgv_01kvnwmagwf27rc9d7zef4qksf"    }  ]}'
Example Response
{  "data": {    "confirmationRequired": true,    "offlineWidgets": [      {        "widgetId": "ewgt_01kvnwmagwf27rc9d7zef4qksf",        "name": "Homepage banner"      }    ],    "displacedLiveVersions": [      {        "widgetId": "ewgt_01kvnwmagvf27rc9cze5rm9e1r",        "name": "Starter questions",        "versionId": "ewgv_01kvnwmagwf27rc9d7zef4qksf"      }    ]  }}

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.

Get a widget experiment

Returns one experiment with, for each arm, the sessions assigned and the sessions that started a conversation (the start rate), and the verdict. The start rate is the only measure that decides; the counts are of sessions, never purchases and never incremental. A result that is not `conclusive` means the test cannot tell yet, never that the versions are the same. The widget in the path may be the widget of either arm; any other widget is a `404`.