Installation
Add the Spar script to your site, confirm Spar can see it, and set up conversion tracking.
Spar needs its script on your site to run A/B tests and record conversions. Settings > Installation gives you the snippet and tells you whether Spar has seen it yet.
If the site is connected through Shopify, a yellow banner at the top says so. Shopify stores load the script through the Spar app embed in the theme, so you only need the snippet if that embed is turned off.

Script snippet
The Script snippet card shows the code to paste into the <head> of every page you want to track. Hover over it and click the copy icon. The snippet is two short script tags: the first lets your pages call window.spar.track() before the main script finishes loading, and the second loads Spar's script with your site's embed key attached.
There are two versions on separate tabs:
- Regular is the default.
- Anti-flicker adds a few lines that hide the page for up to 1.5 seconds while a running test applies its changes, then fade it in. Use it if visitors see the original page flash before a variation appears. It can delay how fast the page shows up.
Script status
Script status tells you whether Spar has detected the script:
- Script found in the page source of your site, or Script detected. Last seen with a time. You're set.
- Not detected yet. Add the snippet, then click Check again.
- Script not detected. Last seen some time ago. The snippet has probably been removed from your site.
The check loads your page and looks for the snippet in its HTML. If you install Spar through a tag manager, the check can't see it there, so the status relies on pageviews reported by the script instead.
Conversion tracking
Record a conversion by calling window.spar.track() with an event name on the page where it happens, for example window.spar.track('checkout_completed').
The table below the example lists the event name each objective needs, based on your business model. The Also required column lists anything extra, such as a denominator event or a metadata key for an order value. If there are more than six, click View all to see the rest.
Once the script is installed, Spar records some events with no extra code, including session starts, engaged sessions, clicks on phone links, form submissions, email captures, scroll depth, and product views. If your site already pushes GA4's standard ecommerce events (add_to_cart, begin_checkout, purchase) to the data layer, Spar picks those up too. Stores connected through Shopify record purchases automatically. Otherwise, purchase and cart events need a window.spar.track() call or one of the options below.
Checkout success page
This card only appears for sites that aren't connected through Shopify.
If your checkout sends shoppers back to a thank-you page on your own domain, enter a URL pattern for that page, for example https://yoursite.com/thank-you*, and click Save changes. Spar records a checkout_completed conversion whenever a visitor lands on a matching URL.
This works with Stripe's hosted Checkout, which redirects back to your site. PayPal and Paddle checkouts often finish without any redirect, so for those, call window.spar.track("checkout_completed", { ... }) from your own success callback or use the server-side conversions API. A success page only counts the conversion, not the order value, so average order value and units per transaction still need ecommerce events or the server API.
Browser extension
The Spar Inspiration Capture for Chrome card links to the Chrome extension. Click Add to Chrome to install it. See Inspiration for how captures work.
Regenerate embed key
The embed key in your snippet identifies your site to Spar. It's visible in your page source, so it isn't a secret. If you need to invalidate an old snippet, click Regenerate key and confirm. The old key stops working right away, so paste the new snippet onto your site immediately.
Server API key
If your checkout never returns to your site and can't run the Spar script, your backend can send conversions to Spar directly. Click Generate key to create a server key for that. Unlike the embed key, this one is a secret. Copy it when it appears, because Spar won't show it again.
Once a key exists, the button becomes Rotate key. Rotating stops the current key immediately, so update your backend with the new one. See Track conversions server-side for the full setup.
Last updated on