ABConvertProvider tracks on its own; track, trackExposure and setConsent come from useABConvert(), or from the client on a stack without React.
Track events
These events feed your results:
ABConvert’s web pixel does not run on a custom storefront’s pages. That is why the SDK sends storefront events itself.
A custom storefront has no Shopify templates, so scope a test’s engagement by page, not by template.
Exposure
An exposure is the moment a test could first affect the visitor. It is what the Visitors who experienced the test view in your results counts, and what counts differs by test type. Reading data never records an exposure. An exposure is recorded in one of these ways:Record a price exposure
CalltrackExposure with the test ID from the Price object, in the browser, once the price is on screen. The SDK records one exposure per test per visit, so calling it from every price on a collection page is fine.
Browser (component)
Record an offer exposure
CalltrackExposure with the offer’s experimentId once your offer banner or message is on screen. Checkout applies the discount either way, but only this call counts the visitor under Visitors who experienced the test.
Browser (component)
Page views and add to cart
On Hydrogen, the provider from the Hydrogen guide listens to Hydrogen’s own analytics, so these need no code. On every other stack, nothing publishes them: calltrack with these event names.
Browser (component)
page_viewed also keeps the visitor’s session alive: a session ends 30 minutes after the last event it records. Product views and add to cart give a test its per-product results, and the results of a product group attached to it. The SDK sends an event only for a visitor who is in at least one running test, and never for a forced or preview visit. To see events, launch a test and open your storefront as a new visitor, without a preview link.
Custom events
Calltrack with the name you gave the event in ABConvert. This works the same on every stack. The SDK sends custom events for every visitor, in a test or not. A name that matches no custom event in ABConvert is dropped, with a warning in the browser console.
Browser (component)
Checkout steps and orders
ABConvert tracks these in Shopify checkout, where Shopify loads ABConvert’s web pixel for any storefront. The pixel reads the visitor ID and test groups from the checkout’s attributes, which you wrote through the cart, and the order carries the same attributes. You add nothing beyond connecting the cart.Cookies and storage
You do not manage cookies or browser storage for ABConvert. The SDK sets first-party cookies on your storefront’s domain for the visitor ID, the current visit, and the decisions it has made. It reads them on every request, so a visitor keeps the same test group on the server, in the browser, and on return visits, whatever they answer to your cookie banner. For your cookie policy, these are the cookies:
The SDK also keeps a flag per test in
sessionStorage, so an exposure is recorded once per visit.
You do three things:
- Pass
requestwhen you create the client on the server, and addgetSetCookieHeaders()to the response. Your stack guide’s setup step does this; on Next.js, the middleware does. - Do not cache a response that sets an ABConvert cookie.
- If you ask visitors for cookie consent, tell the SDK the visitor’s choice.
Consent
Until a visitor allows analytics, the SDK tracks nothing. What it would send waits until they allow, and is dropped if they decline. The SDK sets its cookies whatever the visitor answers, so they see the same test group on every page and at checkout. We trade a cookie set before the answer for a visit that stays consistent: without it, a visitor who has not answered could see one price on a product page and another in the cart. Check that this fits your cookie policy. On Hydrogen, the client and provider from the Hydrogen guide read the visitor’s choice from Shopify’s Customer Privacy API, and you pass nothing. If another stack loads that API, setexpectCustomerPrivacy: true in createABConvert, and expectCustomerPrivacy on ABConvertProvider or in the options of hydrateABConvert, to get the same behavior.
Otherwise, pass the choice when you create the client:
Server
Browser (component)
consent, the SDK reads Shopify’s _tracking_consent cookie when the visitor has one, and otherwise treats analytics as allowed.