ntb.js
Use it
const variant = ntb('hero'); // 0 or 1, sticky for this browser
if (variant === 1) document.body.classList.add('hero-b');
ntb('cta-copy', 3); // three-way test → 0, 1, or 2
Assignment is uniform random, persisted in localStorage under
ntb:<test>. The exposure fires once per test per page load — SPA route
changes don't re-fire it. Analyze by unique visitors per variant, not raw events.
Where exposures land
-
GA4 —
dataLayer.push({event: 'ab_assigned', ntb_test, ntb_variant}), readable by gtag.js and GTM. Register the two params as custom dimensions to report on them. -
Umami —
umami.track('ab_assigned', {test, variant}), with a short poll so a deferred Umami script still catches the event. -
umami-shopify —
Shopify.analytics.publish('umami:ab', {test, variant}); the custom pixel forwards each publish to Umami as oneab_assignedevent, sequenced after the pageview.