Change an experiment
const url = 'https://digize.com/api/v1/analytics/experiments/example';const options = { method: 'PATCH', headers: { 'Idempotency-Key': '5f1c2a8e-3b7d-4c55-9a0e-1f2d3c4b5a69', 'x-api-key': '<x-api-key>', 'Content-Type': 'application/json' }, body: '{"name":"example","hypothesis":"example","pages":["example"],"traffic":1,"variants":[{"name":"example","weight":1,"swaps":[{"selector":"example","op":"text","attribute":"example","value":"example"}],"css":"example","path":"example","siteId":"example"}],"goal":{"kind":"lead","match":""}}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request PATCH \ --url https://digize.com/api/v1/analytics/experiments/example \ --header 'Content-Type: application/json' \ --header 'Idempotency-Key: 5f1c2a8e-3b7d-4c55-9a0e-1f2d3c4b5a69' \ --header 'x-api-key: <x-api-key>' \ --data '{ "name": "example", "hypothesis": "example", "pages": [ "example" ], "traffic": 1, "variants": [ { "name": "example", "weight": 1, "swaps": [ { "selector": "example", "op": "text", "attribute": "example", "value": "example" } ], "css": "example", "path": "example", "siteId": "example" } ], "goal": { "kind": "lead", "match": "" } }'Changes an experiment’s set-up. A draft changes freely. Once it has run, its name, hypothesis and goal change; while paused, its share of traffic and weights too, and new variants can be added after the existing ones (each is then compared only with the control’s visitors from when it joined). What an existing variant shows and the pages can’t change, and variants can’t be taken away, or the results would mix two tests. Needs sites:write as well.
Needs the analytics:write permission.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”The experiment’s id, from analytics.experiments.list.
Header Parameters
Section titled “Header Parameters”Makes the request safe to send again: for 24 hours the same key and request answer the first response without repeating the change.
Example
5f1c2a8e-3b7d-4c55-9a0e-1f2d3c4b5a69Request Bodyrequired
Section titled “Request Bodyrequired”object
What it tests, in a few words.
What it should show and why, in a sentence.
The pages it runs on: paths such as / or /pricing, * at the end for every page under one. A site experiment takes every request of a visitor in it once they’ve seen one of these.
The share of visitors in the test, in percent (all when left out); the rest see the control and aren’t counted.
The control first (it changes nothing), then 1 to 3 variants.
object
Such as Control or Shorter form.
Its share of the test’s visitors, in percent; the weights add up to 100, even when left out.
Content: the changes to the page, in order.
object
A CSS selector HTMLRewriter takes: best a slot the site marked, [data-digize-slot=“hero-title”], else an #id or a tag the page has one of (analytics.experiments.elements lists them). No sibling selectors (+, ~).
Text sets its text, html its inner HTML, replace puts HTML in its place, attribute sets one attribute, remove takes it out.
Content: CSS added to the page’s head, such as a button’s colour.
What counts as converting for a visitor after they saw a variant, on any of the workspace’s sites: a form sent (lead), a booking, a checkout started, an order paid (purchase, with its revenue), a page reached, a tracker event, or scrolling a tested page down so far (scroll).
object
Lead: a form’s name (its _form field), or empty for any form; page: a path, * at the end for every page under it; event: a tracker event’s name; scroll: how far down one of the tested pages, in percent: 25, 50, 75, 90 or 100. Empty for booking, checkout and purchase.
Responses
Section titled “Responses”Done
object
The site’s address, its own domain first.
object
object
Opens this variant of the first page for whoever follows it, counting nothing.
object
Ended with its winner shown to every visitor, until the change is in the site’s code.
Example
{ "kind": "content", "variants": [ { "key": "a", "swaps": [ { "op": "text" } ] } ], "goal": { "kind": "lead" }, "status": "draft", "winner": "a"}What was sent isn’t valid (invalid).
object
object
object
Example
{ "error": { "code": "invalid" }}No key, or one that’s unknown, off or expired.
object
object
object
Example
{ "error": { "code": "invalid" }}The key doesn’t have the permission this needs.
object
object
object
Example
{ "error": { "code": "invalid" }}Nothing has that id (not_found).
object
object
object
Example
{ "error": { "code": "invalid" }}A request with the same Idempotency-Key is still running (conflict).
object
object
object
Example
{ "error": { "code": "invalid" }}The Idempotency-Key was used with a different request.
object
object
object
Example
{ "error": { "code": "invalid" }}Over the rate limit; see retry-after.
object
object
object
Example
{ "error": { "code": "invalid" }}