Build a test
build_testCreates a LiveVariant test and returns every URL needed to run it, plus a freshly generated stats secret.
Pass variants to test one element, or slots to test several at once (hero image AND call-to-action, say). With slots the test optimizes the COMBINATION: one model learns how the elements interact, which two separate tests structurally cannot see. There is no algorithm to pick either way; every test runs the same joint model, sized from its shape.
By default, nothing is registered anywhere: the config IS the test, encoded into the URLs, and the test's identity is a hash of it. Pass publishableKey on an account-enabled deployment to also register the new test to that key's organization, so it appears under My tests; the config and URLs are still the test, and registration failure is returned as a warning rather than failing the build. Editing a variant later produces a DIFFERENT test with its own empty history, which is usually what you want per campaign but is worth saying out loud to whoever you are building this for.
The stats secret is returned once and never again. Only its hash goes into the config, so nobody, including this service, can recover it. Give it to the person who will read the results.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | No | A label for your own reference, and the one field worth spending a merge tag on in a recurring ESP template: it is part of the test's identity, so n={{campaign_name}} mints a separate, separately readable test per campaign, and the name is what list_tests searches. | |
| slots | No | Multi-element test: variants per element, keyed by a short name like "hero" or "cta". The test serves and learns combinations. | |
| region | No | Where the test's state lives. A placement hint (wnam, enam, sam, weur, eeur, apac, oc, afr, me) or "eu" for the EU jurisdiction (state guaranteed created and kept inside the EU). Defaults to the creator's own region when the host can tell; without any, state is born wherever the FIRST request comes from, which in email is routinely a mail provider's US datacenter. | |
| context | No | Dimensions to learn a separate winner for. | |
| variants | No | Single-element test: two or more variants. The first is the control. | |
| redirectUrl | No | Where clicks land when a variant does not say. | |
| variantParam | No | Stamp the served combination into this parameter on redirect, e.g. "utm_content", so the test shows up in the customer's own analytics. | |
| slotRedirects | No | Where clicks on ONE element land, when elements point at different pages (a hero leading to the campaign landing page, a CTA below it to pricing). Keyed like `slots`. Falls back to `redirectUrl`; a variant's own redirectUrl still wins over both. Setting any of these means every click link must name its slot, which slotLinks does for you. | |
| publishableKey | No | Registers the new test to the organization identified by a publishable key the user provides for an organization they administer. Result access stays tied to this test's stats secret. Only works on account-enabled deployments; elsewhere a warning says so and the test still works. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| urls | Yes | ||
| slots | Yes | Canonical slot order with variant names, as stats reports them. | |
| config | Yes | The encoded config: this is the test. | |
| region | Yes | Where the test's state will live; null means first-request placement. | |
| testId | Yes | ||
| warnings | Yes | ||
| slotLinks | No | Multi-slot tests only: the serve/click URL per element. The bare urls.serve returns 400 for these tests, because a serve must say which element it renders. The bare urls.click works when the destination is uniform (a config redirectUrl or ?to=); per-slot clicks matter as soon as an element carries its own destination, via slotRedirects or a variant redirectUrl. | |
| statsSecret | Yes | Shown once. Store it now. | |
| combinations | Yes | How many distinct combinations the test chooses between. | |
| destinations | No | Redirect destinations and whether each is a verified domain. Unverified means visitors see a 'Redirecting you to…' continue screen before landing; relay the verification warning to the user when present. | |
| registeredTo | No | The organization the test was registered to, when a publishableKey was given and accepted. | |
| emailTemplate | No | Query-parameter spelling per slot for an ESP template: wire it once, then campaign managers fill only the merge fields. All links share one identical config string (names, ctx dims, kh and the landing r=/sr= included, so serve and click stay ONE test); image links add &slot= per element. The click link needs no slot unless the test sets slotRedirects, in which case each element's click link carries its own. Absent when a variant has inline content or its own redirectUrl, which the parameter form cannot express. |