AskSpot analytics on Shopify: storefront and checkout

Shopify is a special case for chat analytics: the storefront behaves like any other site, but the checkout runs Custom Pixels in an isolated sandbox. This guide covers both – how to load the AskSpot chat and its measurement on the storefront, and what actually works (and doesn’t) on the Shopify checkout.

Key takeaways

  • On the storefront, everything from the main GA4 guide works unchanged – load the widget and the dataLayer bridge through GTM.
  • On the checkout, Shopify runs Custom Pixels in a sandbox: the script loads, but the widget won’t render – by design, not a bug.
  • The analytics part can still work in the sandbox – it can listen for checkout_completed and send a conversion to the AskSpot API.
  • Access to conversation memory on the checkout needs testing; the cookie fallback is the reliable workaround.

This is a companion to the main guide, tracking the AskSpot chat in Google Analytics – read that first for the widget events, the dataLayer bridge, GTM and GA4 setup. Here we only cover what is specific to Shopify.

Storefront (home, categories, product pages)

The ordinary case. You load the widget through GTM or the theme (theme.liquid), and the bridge through GTM. Everything in the main GA4 guide works unchanged.

Checkout – three facts to know

  • Fact 1: Custom Pixel runs in a sandbox. Shopify runs Custom Pixels in an isolated iframe (Web Pixels API), with no access to the checkout page DOM. Consequence: the script loads, but the widget won’t render. That’s not a bug – it’s how Shopify works.
  • Fact 2: the analytics layer can work. Besides the chat window, our script loads analytics logic. In the sandbox the widget has nowhere to draw itself, but the analytics part has a chance to work – it can listen for Shopify events in the pixel environment (including checkout_completed) and send a conversion to our API.
  • Fact 3: access to conversation memory needs testing. We keep conversation memory in a hidden chat frame (iframe). Because the checkout usually runs on a subdomain of the same parent domain as the shop, the browser treats it as the same site and a conversation started on the storefront should be visible there. But a strongly isolated Custom Pixel sandbox may cut that off.

This needs a test on your specific install. Don’t assume it works – check it (procedure in the main guide’s Debugging section). If the sandbox cuts off access to conversation memory, the workaround is saving conversationId in a cookie on the shop domain (attribution, method C) – the cookie works independently of these limits.

Code for the Custom Pixel

const ASKSPOT_SCRIPT_SRC =
  'https://chat.askspot.io/api/v1/integration/{YOUR_INTEGRATION_ID}/embed-script';

let askSpotLoaded = false;

function loadAskSpot() {
  if (askSpotLoaded) return;
  askSpotLoaded = true;
  const script = document.createElement('script');
  script.async = true;
  script.crossOrigin = 'anonymous';
  script.src = ASKSPOT_SCRIPT_SRC;
  document.head.appendChild(script);
}

const getCookiebotConsent = async () => {
  try {
    const cookieString = await browser.cookie.get('CookieConsent');
    if (!cookieString) return null;
    return {
      marketing:   cookieString.includes('marketing:true'),
      statistics:  cookieString.includes('statistics:true'),
      preferences: cookieString.includes('preferences:true')
    };
  } catch (e) {
    return null;
  }
};

async function loadAskSpotIfAnalyticsConsentGranted() {
  const consent = await getCookiebotConsent();
  if (consent?.statistics) loadAskSpot();
}

analytics.subscribe('checkout_started', () => {
  loadAskSpotIfAnalyticsConsentGranted();
});

GTM or Custom Pixel on the checkout?

GTMCustom Pixel
Works on Shopify checkoutonly with Checkout Extensibility (Shopify Plus / new checkout)✓ always
Consent✓ with Consent Mode, one placemanual, cookie parsing
Access to Shopify events (checkout_completed)indirectly via the dataLayer✓ natively via analytics.subscribe
Isolationnonesandbox – no DOM, possible trouble accessing conversation memory
Adblockers⚠ block gtm.jsless susceptible

Recommended order of action:

  1. Storefront through GTM (consent, one place, the whole path). Remove the frontend script so you don’t duplicate.
  2. Ask AskSpot to hide the bubble on the cart and checkout – don’t fiddle with conditional loading.
  3. Checkout: first check whether you need a Custom Pixel at all. If conversions are meant to go to the AskSpot API, not your GA4 – check with us whether a server-side variant (attribution, level 3) is enough.
  4. If a Custom Pixel is needed – deploy it on a test pixel / test shop first, verify the QA checklist items, and only then go to production.

For placement modes and the full integration picture, see the Shopify integration. To connect order data (order status in chat), see how to connect Shopify to AskSpot.

Why doesn’t the chat widget show on the Shopify checkout?

Shopify runs Custom Pixels in an isolated sandbox with no access to the checkout DOM, so the widget has nowhere to render. That’s expected. The analytics part of the script can still run and send conversions to the AskSpot API.

Do I need a Custom Pixel at all?

Check first. If you only need conversions attributed to conversations, a server-side variant sending them to the AskSpot API may be enough – ask your AskSpot contact. Use a Custom Pixel only when you specifically need checkout-side events in the sandbox.

Will a conversation from the storefront carry over to the checkout?

It should, because the checkout usually lives on a subdomain of the same parent domain – but a strongly isolated sandbox can cut it off. Test it, and if it’s blocked, save the conversationId in a cookie on the shop domain as a fallback.

LinkedIn

Written by

AskSpot builds AI Chat and Inbox Agents for e-commerce: on-site product advice and 24/7 support across email, chat and marketplaces, in 200+ languages.

Case studies

Real results for e-commerce stores

See how online retailers use AskSpot to automate conversations, reduce support workload and grow sales.

All case studies

Ready to make every conversation sell?

Sign up and set up your Agent with the panel's setup assistant – or book a demo and we'll show you AskSpot on your own catalog.