Conversion pixel on Shopify
Install the Styrar conversion pixel on Shopify using a Custom Pixel.
Shopify no longer supports pasting a raw <script> tag into checkout — third-party tracking goes through Custom Pixels, a sandboxed environment built on Shopify's Customer Events API. This guide shows how to wire the Styrar conversion pixel into a custom pixel.
The sandbox doesn't give you direct DOM access, so instead of embedding Styrar's script tag, you call the tracking endpoint directly with fetch whenever a Shopify customer event fires.
Setup
-
In your Shopify admin, go to Settings → Customer events → Add custom pixel.
-
Name it (e.g. "Styrar conversions") and add code like this:
JavaScriptanalytics.subscribe('checkout_completed', (event) => { const url = new URL(window.location.href); const clickToken = url.searchParams.get('styrar_ck') || (typeof localStorage !== 'undefined' && localStorage.getItem('styrar_ck')); if (!clickToken) return; fetch('https://api.styrar.com/v1/pixel/track', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ clickToken, eventName: 'purchase', value: event.data.checkout.totalPrice.amount, eventData: { currency: event.data.checkout.totalPrice.currencyCode }, }), keepalive: true, }); });Subscribe to whichever event matches the conversion you care about —
checkout_completed,payment_info_submitted,product_added_to_cart, and others are all available. -
Allow network access. Shopify blocks outbound requests from custom pixels by default. In the same pixel's settings, add
api.styrar.comunder Permissions → Connect to third-party servers, or the request above will silently fail. -
Set the pixel to Active.
A note on the click token
Shopify's pixel sandbox can't read localStorage the way a normal page can, so styrar_ck needs to still be present in the URL (or carried through as a cart attribute) by the time your event fires. If your checkout flow strips the query parameter before checkout_completed, capture the token earlier — on page_viewed — and store it as a cart attribute so you can read it back later.
This still uses the exact same public, unauthenticated POST /v1/pixel/track endpoint as every other platform — there's no Shopify-specific app to install on Styrar's side.