Install the SDK
Two snippets, no dependencies. The boot script is ~1.4 KB gzipped and loads the full SDK (~4.2 KB gzipped) asynchronously. It works on any website — plain HTML, React, Vue, Shopify, anything that can include a script tag.
Choose one path per test — snippet or API, not both — otherwise visitors get counted twice. Server-side? The integration guide covers assignment, stickiness, and failure handling.
Choose a test
Picking a test pre-fills its key into every snippet below. Link here from a results page with /install?test=<key>.
Serving from a different domain?
The snippets below already point at https://your-provebetter-host. If your site loads this page from a different origin, overwrite it here:
1Paste the boot script in <head>
Synchronous, first in <head>, on every page you want to test. It assigns the visitor a first-party cookie (pb_vid, 180 days) so they always see the same variant, and hides test elements for at most 2 seconds while their variant loads — visitors on a very slow connection simply see the control page and are not counted in the test.
<script src="https://your-provebetter-host/boot.js"></script>2Mark up your variants
Wrap each variant's content in a container with data-pb="your-test-key" — replace with your test's key from the Tests page or pick it above. The control variant ships visible; challengers ship hidden so the page is correct even before (or without) JavaScript. The SDK reveals exactly one variant per visitor.
<div data-pb="your-test-key">
<div data-pb-variant="A">Control headline</div>
<div data-pb-variant="B" hidden>Challenger headline</div>
</div>
<!-- Hide an element when a specific variant wins -->
<div data-pb-hide="your-test-key:B">Shown only when B is NOT active</div>3Track conversions
Call ProveBetter.track() on the action you're measuring — a signup, a purchase, any click. With one active test on the page, no test key is needed. Exposures are recorded automatically the moment a variant is applied.
// Conversion — attributed to the page's single active test
ProveBetter.track("signup_click");
// Conversion attributed explicitly to this test
ProveBetter.track("purchase", { test: "headline-test" });
// Read the resolved variant in your own code
const v = ProveBetter.variant("headline-test"); // "A".."E" or nullCheck that your snippet is live
After pasting, open your site, and ProveBetter checks here that the snippet actually booted.
QA checklist
- Draft tests don't run. Launch the test (status “Running”) before expecting traffic to be split.
- QA tip: press Ctrl+Shift+Alt+T on any page with your snippet to open variant preview — pick a variant to see exactly what its visitors see, or go back to normal. Preview views are never counted in results.
- Timeout: set
window.ProveBetterConfig = { antiFlickerMs: 4000 }just before the boot script to give slow connections more time. - Single-page apps: variant elements are re-scanned automatically on pushState / replaceState / popstate navigation.
- Sticky by design: the same visitor keeps the same variant across visits (cookie) and across traffic-percentage changes (deterministic server-side hashing).