Getting started
Quickstart
Add the snippet, create a flag and run your first experiment in about ten minutes.
This guide takes a website from nothing to a running A/B test. The same flag works unchanged in a React Native app or on your server; the SDK tabs below show how.
Create a project
Sign up and create a project, for example
web. Every project starts with two environments,developmentandproduction, each with its own SDK key (pk_…). SDK keys are public: they only allow downloading that environment's flags and sending events.Install the SDK
Paste the snippet at the top of
<head>, before other scripts, with your SDK key. The project's Install page has it ready with the key filled in, and shows a live check: when the snippet first loads on your site, then when the first event arrives.<!-- 1. Anti-flicker: hide the page until flags are ready (1.5 s at most) --> <style id="liftcanary-hide">body{opacity:0!important}</style> <script>setTimeout(function(){var s=document.getElementById("liftcanary-hide");if(s)s.remove()},1500)</script> <!-- 2. Lets the page call liftcanary before the SDK has loaded --> <script>window.liftcanary=window.liftcanary||{q:[],onReady:function(f){this.q.push(f)},track:function(e,o){this.q.push(["track",e,o])},activate:function(k){this.q.push(["activate",k])},consent:function(g){this.q.push(["consent",g])}};</script> <!-- 3. The SDK --> <script src="https://cdn.liftcanary.com/sdk/v1/liftcanary.js" data-sdk-key="pk_..."></script>The first
<style>hides the page until flags are ready (at most 1.5 s) so visitors never see the original flash before a variation. The small inline script lets you callliftcanarybefore the SDK has loaded. Both are explained in Website snippet.Create a flag
In Flags → New flag, create
new_checkout. A new flag has two variations,offandon, and is switched off in every environment. Add a variable if you want to change values without a deploy, for examplebutton_text(text) with the default “Buy now”.Use it in your code
liftcanary.onReady((sk) => { if (sk.isEnabled("new_checkout")) showOnePageCheckout(); button.textContent = sk.variable("new_checkout", "button_text", "Buy now"); });Track a conversion
Record what you want to improve. Revenue goes in
value.JavaScript liftcanary.track("purchase", { value: 129.9, properties: { currency: "TRY" } });Then add a goal for it in Goals (event
purchase). Clicks, page visits, form submissions and scroll depth can be tracked by the snippet without code: see Goals and metrics.Start an experiment
In Experiments → New experiment, pick the flag and the environment, choose who takes part (everyone, an audience or a location), the traffic split and the primary goal. Start it, and the results page fills in as visitors arrive. Results are safe to check at any time: see Results and statistics.
Ship the winner
When a variation wins, Stop → Ship turns the experiment into a 100% rollout of that variation for the same audience. Later, remove the flag from your code and archive it.
Check it works#
- Open your site with
?liftcanary_debug=1: the console shows the visitor's attributes and every decision with its reason. - The Install page shows when the last event arrived from each environment.
- Add yourself as a user override on the flag to see a variation before anyone else does.