LiftCanary

Guides

No-code tests, A/A and personalizations

Variations made of CSS and JavaScript, A/A tests to check your setup, and personalizations for an audience.

Test a change without touching your code: click elements on your own page in the visual editor to change their text, colors, links and images, or write a bit of CSS and JavaScript; the website snippet applies them on the pages you choose. The same mechanism runs A/A tests (two identical originals, to check your setup) and personalizations (show a change to an audience, with nothing to compare). Tests are listed under Experiments, personalizations under Personalizations, and both are managed from their own pages: you never need to know about flags. A flag is still created behind the scenes, because flags are what decides who sees what on every platform; it stays out of the way, under Feature flags → Created automatically, and opens the experiment or personalization it belongs to.

Experiment types#

TypeWhat it doesCode
A/BVariations against the original page. Made without code (CSS/JS here) or in your code (a flag your developers read).Optional
Split URLSend visitors of a page to different URLs. See Redirect tests.No
MultipageOne variation across several pages, e.g. the whole checkout. Each visitor gets one variation on every page of the set.Optional
A/ATwo identical copies of the original page. No goal should differ significantly; if one does, check tracking and the traffic split first.No
PersonalizationShow a change to an audience on some pages. No comparison and no winner: it stays until you turn it off (Personalizations → New personalization).No

Set one up#

  1. Experiments → New experiment, pick A/B (or Multipage) and keep Without code (CSS / JavaScript).
  2. Choose the pages: a saved location or URL rules. A location with a trigger (click, visible, element) applies the changes when it activates.
  3. For each variation, click Add CSS and/or Add JavaScript, or leave them empty to use the visual editor. The original page is always the control.
  4. Pick the audience, the goals (Choose goals selects several at once and marks the primary one) and start.

Change a variation's CSS or JavaScript later on the experiment's page, under Page changes. Saving publishes to every environment within seconds.

Visual editor#

Change your page by pointing at it. At the top of the experiment's (or personalization's) page, in the Visual editor box, enter the address of a page the test runs on and click Open visual editor. Your page opens in a new tab with the editor: the panel on the left, your page on the right.

The visual editor on your own site: the panel on the left, your page on the right. Changes preview live; nothing reaches visitors until you save.

  1. 1Select to click elements and change them, Browse to use the site normally (open a menu, go to another page).
  2. 2The selected element, with its name and size. Its changes are saved for a CSS selector you can edit in the panel.
  3. 3The panel: where the element is, its text, link or image, typography, background and border, size and spacing, position, new content, classes and HTML. What this variation changes is marked in amber.
  4. 4The variation you're editing. Each one has its own changes; the original page can't be changed.
  5. 5The page at desktop, tablet or phone width, right there, saved or not.
  6. 6Save publishes to every environment; visitors see it within seconds.
  7. 7Warnings over the page: the test is running, or this page isn't one of the test's pages.
  • Select mode: hover to see elements, click one to change it. Browse mode uses the site normally (open a menu, go to another page; the editor stays on). The address in the bar is the page being edited: type another path of your site and press Enter to go there.
  • The panel changes the element's text, a link's address (and whether it opens in a new tab), an image's URL and alt text, a field's placeholder and the tooltip of a link, button or image; under Typography its color, font size and weight, line height, letter spacing, alignment, italic, underline and strikethrough; under Background & border its background, border, corner radius and opacity; under Size & spacing its width, maximum width, padding and margin. Hide, at the bottom of the panel, hides it; Edit HTML replaces its content.
  • What the variation changes is marked: its section gets a dot and the property's name turns amber. Click an amber name to go back to the site's own value, or Reset element to undo everything done to the element. In a number field, ↑ and ↓ change the value (Shift for steps of ten).
  • With nothing selected, the panel lists the variation's changes, one row per element: point at a row to see the element on the page, click it to select it, or remove its changes with the bin.
  • Classes: remove one of the element's classes or add one the site already has, e.g. another button style. Its other classes stay as the site sets them.
  • The top of the panel shows where the element is: click one of its parents to select it (hovering shows it on the page), or pick an element inside it. The selector is editable there, with the number of elements it matches.
  • Position: Move up and Move down put the element before the one above it or after the one below it, e.g. reviews above the price.
  • Add content: a banner, text, button, image or your own HTML, after or before the element or inside it (at the start or end). Start from a template and edit the HTML; the new content is selected right away so you can change its text and style. Select it again later to edit or remove it.
  • Undo and redo (the arrows in the toolbar, or ⌘Z / ⌘⇧Z; Ctrl on Windows) step through your edits, across variations.
  • The desktop, tablet and phone buttons show the page at that width (820 or 390 pixels) right there, with your changes saved or not, so you can check and edit the layout on small screens.
  • Pick the variation in the toolbar; each one has its own changes, previewed live together with its CSS. The original page can't be changed: it's the control.
  • Save publishes to every environment; visitors see it within seconds. Exit closes the editor.
  • When the test is running, a line over the page says so: saving changes what visitors already in it see, and its results will mix the old and the new version. The first save asks you to confirm (once per editor link). Fine for a typo; for anything bigger, add a variation or start a new test.
  • On a page that isn't one of the test's pages (or isn't in its location), a line over the page says visitors won't see the changes there and lists the test's pages, with a button to go to one when it's a plain address.

Your page in the editor#

The page on the right is your own site, shown in a frame of the same address, so it's exactly what you see when you browse it: signed in, with your cart and your cookie choices. Its scripts run as usual, except that it can't navigate the whole tab. Two things to know:

  • A site that doesn't let itself be shown in a frame (X-Frame-Options: DENY, or frame-ancestors 'none' or a frame-src without 'self' in its Content-Security-Policy) gets the editor on the page itself instead, automatically: the panel and the bar float over your page, and Desktop / Tablet / Mobile opens a window of that width (saved changes only). SAMEORIGIN is fine. So are windows narrower than 900 pixels, which always get the editor on the page.
  • If the page doesn't look right in the frame, Edit on the page instead at the bottom of the panel switches for this editor link; Side by side in the bar switches back.
  • While the editor is open your own analytics may count each page twice: once for the tab and once for the frame. This only happens for whoever is editing.

Each change targets a CSS selector the editor picks (an id when there is one, otherwise a short path with classes); edit it in the panel to change every matching element, e.g. all .price elements. Changes are applied before the page is revealed (styles and hiding as CSS) and again when matching elements appear later, for up to 15 seconds after load, so content rendered by JavaScript is covered too. If the site's own script puts its text back after the change (a re-render), the change is applied again, up to 10 times per element. Added content and moves happen once per page view. Visual changes, CSS and JavaScript can be combined in one variation: visual changes first, then the CSS, then the JavaScript.

AI suggestions#

Ask AI at the top of the editor's panel writes variations for you. Select an element (or nothing, for the whole page), describe what you want, such as “make it more urgent” or “add a free-shipping line under the price”, and click Suggest (or press ⌘↵). Up to three alternatives come back, each with a one-line hypothesis; Try shows one on the page (trying another replaces it), and you keep editing it like any change before you save. Undo takes it back.

  • Suggestions use the editor's own changes: text, styles, hiding, links, moving elements and short text banners. They never contain scripts or raw HTML.
  • Copy is written in the page's language and tone. The AI is told not to invent offers, prices, shipping terms or other claims that aren't on the page, but check the wording and any facts before you save.
  • Each Suggest counts once against the plan's AI suggestions for the month (see Pricing); the panel shows how many are left.

The code editor#

CSS and JavaScript are edited in a code editor with syntax highlighting, autocompletion of CSS properties and values and of JavaScript keywords, auto-closing brackets, search (⌘F) and undo. Type a snippet name and press Enter; Tab jumps between its fields.

SnippetInInserts
hideCSS / JSHide an element.
buttonCSSRestyle a button: background, color, radius.
textCSS / JSBigger, bolder text (CSS) or replace an element's text (JS).
mobileCSSA @media block for phones (and desktop for large screens).
insertJSAdd HTML next to an element.
attrJSChange an attribute: a link's href, an image's src.
waitForJSRun once an element appears: for single-page apps and content loaded later.
trackClickJSCount clicks on an element as a goal.
trackJSSend a goal event: liftcanary.track("event").

What the snippet does#

  1. On a matching page it decides the test's flag for the visitor and logs the exposure (only visitors of the tested pages are enrolled).
  2. The variation's CSS goes into a <style> element before the page is revealed, so with the anti-flicker option visitors never see the original first.
  3. The JavaScript runs when the DOM is ready, with liftcanary in scope.
JavaScript of a variation
document.querySelector(".cta").textContent = "Start free";
document.querySelector(".cta")?.addEventListener("click", () => liftcanary.track("cta_click"));

Single-page apps#

Nothing to do: the snippet treats every client-side navigation (React Router, the Next.js router, Vue Router: anything using history.pushState,replaceState or back/forward) as a new page view. Tests and personalizations whose pages now match are applied, the CSS of those whose pages no longer match is removed, visual changes go onto the newly rendered content, and split URL tests redirect from their page. Changing only the #hash doesn't count. A test's JavaScript runs once while you stay on its pages; JavaScript that already ran can't be undone, so write it to be safe on any page, or use waitFor. To run code on every navigation, listen to the liftcanary:navigate event.

To handle navigations yourself (like Convert's "Disable Single Page App Optimizations"), add data-spa="off" to the snippet and call liftcanary.applyChanges() after your router has rendered the new page.

Behind the scenes#

A no-code test is a flag with css and js text variables and the variations off (not in the test), original (the control) and one per change; an A/A test has original and original_b. A personalization has personalized and a rollout rule for its audience. The pages are in the datafile's changes section.

API#

POST /v1/projects/web/experiments
{
  "kind": "changes",
  "name": "Bigger call to action",
  "environment": "production",
  "changes": {
    "include": [{ "type": "startsWith", "value": "/pricing" }],
    "variations": [
      { "name": "Big button", "css": ".cta { font-size: 1.25rem; }" },
      { "name": "Green", "css": ".cta { background: #16a34a; }", "js": "document.title += ' (new)';" }
    ]
  },
  "primaryMetric": { "eventKey": "signup", "type": "conversion" },
  "start": true
}

changes

location
key
A saved location; or send include/exclude rules.
include / exclude
UrlMatch[]
Page rules, like redirect tests.
variations
[{ name, css?, js? }]
1–9 changed variations for changes; omit for aa. Each CSS and JavaScript up to 20 KB.

"kind": "aa" takes the same body without variations. A personalization has its own endpoint (called deploys in the API):

POST /v1/projects/web/deploys
{
  "name": "Black Friday banner",
  "environment": "production",
  "audience": { "attribute": "country", "op": "eq", "value": "TR" },
  "changes": { "include": [{ "type": "simple", "value": "/" }], "css": ".bf-banner { display: block !important; }" },
  "start": true
}

It answers with the experiment and the flag it created: { "id": "…", "flag": "deploy_black_friday_banner", "environment": "production" }. A personalization is an experiment record with "kind": "deploy" and no metrics, shown on the Personalizations page. POST …/experiments/:id/start turns one saved switched off on, and …/stop turns it off: its rule is removed and everyone sees the page as it is.

Visual changes#

The visual editor saves each variation's changes in the flag's visual JSON variable (next to css and js): a list the snippet applies in order. You can also write it yourself with PATCH /v1/projects/:p/flags/:flag; up to 200 changes and 50 KB per variation.

The visual variable of a variation
[
  { "selector": "#hero h1", "type": "text", "value": "Start free today" },
  { "selector": ".cta", "type": "style", "styles": { "background-color": "#16a34a", "border-radius": "999px" } },
  { "selector": ".cta", "type": "attr", "name": "href", "value": "/signup?plan=pro" },
  { "selector": ".cta", "type": "class", "add": ["btn-primary"], "remove": ["btn-ghost"] },
  { "selector": "a.size-guide", "type": "attr", "name": "target", "value": "_blank" },
  { "selector": ".promo-strip", "type": "hide" },
  { "selector": ".usp", "type": "html", "value": "<strong>Free</strong> returns" },
  { "selector": "#cart", "type": "insert", "position": "before", "html": "<div class=\"strip\">Free shipping today</div>", "id": "k3x9m2" },
  { "selector": "#reviews", "type": "move", "position": "before", "target": "#price" }
]

A visual change

selector
string
A CSS selector; every matching element is changed.
type
"text" | "html" | "style" | "hide" | "attr" | "class" | "insert" | "move"
Replace the text, replace the HTML, set styles, hide, set an attribute, add or remove classes, add content, or move the element.
value
string
For text, html and attr. Links and image URLs must be http(s) or relative.
styles
{ property: value }
color, background-color, font-size, font-weight, font-style, text-decoration, text-align, line-height, letter-spacing, padding, margin, border-radius, border, width, max-width, opacity.
name
"href" | "src" | "alt" | "title" | "placeholder" | "target"
For attr. A target is _blank (a new tab, which also sets rel="noopener noreferrer") or _self.
add, remove
string[]
For class: class names to add and to remove (at least one, up to 20 in all; no spaces or quotes). The element's other classes are left alone.
position
"before" | "after" | "prepend" | "append"
For insert: next to the element, or inside it at the start or end. For move: before or after the target.
html, id
string
For insert: the content (up to 20 KB), and an id of lowercase letters and digits (up to 16). Added elements carry data-liftcanary-insert="id", so they're never added twice and can be targeted by other changes.
target
string
For move: where the first element matching selector goes. Each move happens once per page view.

The dashboard opens the editor with POST /v1/projects/:p/flags/:flag/editor-sessions (editor role), which answers { "token": "ed_…", "expiresAt": "…" }, and adds #liftcanary_editor=<token> to your page (after #, so it never reaches your server's logs; the snippet removes it from the address bar at once). The session only opens on a site of its own project, and stops working when you exit or lose the right to edit. With the token the editor reads the variations, where the test is running and its pages (GET /editor/sessions/:token) and saves one (PUT /editor/sessions/:token/variations/:key with { "visual": [...] }); every save is in the audit log as "(visual editor)".