Wix

You will install the snippet site-wide through Wix's Custom Code settings, then record purchases from the Wix Stores Thank You page.

Plan requirement

Custom code on Wix requires a premium plan with a connected domain.

Install the snippet

Your snippet comes from Project Settings → Snippet in the A vs B dashboard:

Copy your snippet from Project Settings → Snippet.
HTML
<script>window.avsb=window.avsb||{};window.avsb.q=window.avsb.q||[];window.avsb.ready=window.avsb.ready||function(f){window.avsb.q.push(f)};window.avsb.on=window.avsb.on||function(n,f){var t=['on',n,f];window.avsb.q.push(t);return function(){t[0]=null}};window.avsb.consent=window.avsb.consent||{set:function(s){window.avsb.q.push(['consent.set',s])},get:function(){return{}}};window.avsb.track=window.avsb.track||{};['event','segment','purchase','cart'].forEach(function(m){window.avsb.track[m]=window.avsb.track[m]||function(a,b){window.avsb.q.push(['track.'+m,a,b])}});(function(){window.avsb._t0=Date.now();window.avsb._df=fetch('https://cdn.avsb.cloud/YOUR_SNIPPET_KEY/datafile.json').catch(function(){});var d=document,e=d.documentElement,s=d.currentScript,a=s&&s.getAttribute('data-avsb-timeout'),t=a==null?3000:+a;if(!(t>0)||window.avsb.version)return;e.style.opacity='0';e.style.pointerEvents='none';window.avsb._t=setTimeout(function(){e.style.removeProperty('opacity');e.style.removeProperty('pointer-events')},t)})();</script><script src="https://cdn.avsb.cloud/snippet.js?id=YOUR_SNIPPET_KEY" data-avsb="YOUR_SNIPPET_KEY" async></script>
HTML9 lines

The first tag is a stub that makes avsb.ready(...), avsb.on(...) and avsb.consent.set(...) calls safe before the bundle loads. Paste both tags into the custom code box.

1

Open Custom Code

In your Wix dashboard, go to Settings, then under Advanced click Custom Code.

2

Add the code

Click + Add Custom Code, paste the snippet tag, and name it A vs B Snippet.

3

Set placement

Set Add Code to Pages to All pages and Place Code in to Head.

4

Apply and publish

Click Apply and publish your site. Check Project Settings → Snippet in A vs B: the badge turns green and reads Installed once your published site sends its first page view.

Record purchases (Wix Stores)

Wix does not let arbitrary page code read order details directly, but Velo (Wix's built-in development platform) exposes the order on the Thank You page. The Thank You page element's getOrder() returns the completed order, which you forward to avsb.track.purchase.

1

Enable Velo

In the Wix Editor, turn on Dev Mode (Velo) from the top bar.

2

Open the Thank You page

Navigate to the Wix Stores Thank You Page in the page selector. Note the ID of the Thank You page element in the properties panel: it is thankYouPage1 by default.

3

Add the page code

In the page's code panel, add the code below, then publish the site.

JavaScript
// Thank You page code (Velo)// docs-example: not typechecked here, because `$w` and the order it returns are// supplied by the Wix Velo runtime inside the Wix editor, not by any package// this repo can install, and this block is pasted verbatim into that editor so// it cannot carry TypeScript declarations.$w.onReady(function () {  $w('#thankYouPage1')    .getOrder()    .then(function (order) {      if (window.avsb && window.avsb.track) {        window.avsb.track.purchase({          orderId: String(order.number),          total: order.totals.total,          currency: order.currency,          subtotal: order.totals.subtotal,          shipping: order.totals.shipping,          tax: order.totals.tax        });      }    });});
JavaScript21 lines

orderId and total (a decimal, for example 49.99) are required; the rest are optional. Orders are deduplicated by orderId with last-write-wins, so a buyer refreshing the Thank You page never double-counts.

Velo code runs in the page, custom code in the head

The A vs B snippet loads from the Custom Code setting in the head. By the time the Velo onReady callback and getOrder() promise resolve, window.avsb is already available. If you load the snippet any other way (for example from Velo itself), make sure it has loaded before calling avsb.track.purchase.

Verify

Place a test order, then open Commerce → Orders in the A vs B dashboard to confirm the order arrived. Then check it was credited to an experiment exposure, the moment a visitor is counted in a test. See the orders & attribution guide for the details.

Was this helpful?