CloseTrace
Product

Track Shopify Cart Abandonment with CloseTrace in 20 Minutes

Install CloseTrace on a Shopify storefront, build a product-to-cart funnel from observed signals, and inspect storefront friction before hosted checkout.

CloseTrace Team · May 18, 2026 · 4 min read

Track Shopify Cart Abandonment with CloseTrace in 20 Minutes editorial illustration

Your Shopify analytics says 71% of carts got abandoned this week. Fine — that's roughly the industry average. What it doesn't say is which step killed each one: the shipping calculator, the discount code field that quietly errored, the Shop Pay popup that never loaded on Safari iOS 17.

That's the gap most marketing teams try to close with session replay. Below is a 20-minute setup that gets CloseTrace recording on your Shopify storefront and turns observed product, cart, and checkout-CTA signals into a funnel. CloseTrace does not record the hosted checkout DOM or send cart-recovery emails in the current release.

Step 1: Drop the snippet into theme.liquid

CloseTrace ships as a single async script. A theme-level install covers product pages, collections, and cart UI rendered by the storefront theme. It does not automatically cover Shopify's hosted checkout DOM.

In your Shopify admin: Online Store → Themes → ⋯ (on your live theme) → Edit code.

Open layout/theme.liquid and paste this just before the closing </head> tag:

<!-- CloseTrace -->
<script async src="https://api.closetrace.com/t.js?k=ct_pk_YOUR_PUBLIC_KEY"></script>

Replace ct_pk_YOUR_PUBLIC_KEY with the public key in Dashboard → Settings → Setup. Copying the server-generated snippet is safest because it also includes the current bundle version. CloseTrace reads the key from the k query parameter; no data-site, data-shopify, or ct('init') call is required.

Save the theme. Hit any product page in an incognito window, add to cart, and check the Live sessions view. You should see one active session within ~10 seconds.

A note on the hosted checkout

Shopify's hosted checkout is isolated from your storefront theme. Standard theme installs therefore cover product, collection, and cart pages, but not the DOM inside checkout. CloseTrace does not currently ship a Shopify Customer Events pixel bridge, so do not paste a custom-pixel example that calls a nonexistent closetrace.track() API.

Step 2: Verify the storefront signals

The current tracker automatically captures page views, clicks, smart button/CTA clicks, scroll depth, form interactions, replay, and heatmap coordinates on pages where the snippet runs. Open a product, click Add to cart, and visit /cart; then inspect that session in CloseTrace. Use the exact page paths and smart-event key shown by that real test session when you build the funnel.

Step 3: Build the cart-to-purchase funnel

In CloseTrace, open Funnels → New and start with the storefront steps the theme exposes:

  1. Page path contains /products/
  2. The observed smart click for your Add to cart button, or page path contains /cart
  3. Page path contains /cart
  4. A checkout CTA smart click, if that click occurs before Shopify leaves the instrumented storefront

Save it as Shopify product → cart. It measures storefront drop-off honestly; it does not claim a purchase event that the current integration cannot observe inside Shopify's hosted checkout.

If you want context on what a healthy version of this looks like, the d2c checkout funnels teardown walks through where carts typically bleed. The benchmarks track Baymard's ~70% abandonment number, but the per-step breakdown is what's actually useful.

Step 4: Use replay to diagnose the drop-off

Open sessions that reached the cart but never produced the checkout CTA signal. The attached session replay can show storefront friction such as a broken cart drawer, discount-code confusion, dead clicks, or a CTA hidden below the fold. CloseTrace does not currently send automated Shopify cart-recovery emails or join sessions with cart tokens; use Shopify's own abandoned-checkout workflow for that job.

What this setup won't catch

One caveat worth saying out loud: a theme-level install cannot record the hosted checkout iframe or its form fields. You get full storefront replay through the cart/checkout handoff, then Shopify owns the remaining checkout telemetry.

If your store ships to the EU, walk through your GDPR posture before enabling analytics. Mark any private element with data-private; capturing a typed email through Lead Recovery is a separate consent question from masking its visual replay value.

Verify it before you trust it

Run one end-to-end test before you tell the team it's live:

  1. Open the store in incognito, visit a product, add it to cart, and click the checkout CTA.
  2. Wait two minutes. The session should appear in Sessions with the product/cart page views and click events.
  3. Confirm the product-to-cart funnel increments and the replay ends at the Shopify checkout handoff.

If the session never appears, confirm that the saved site domain matches the live storefront origin and that the copied public key begins with ct_pk_.

Next thing to do: tomorrow morning, open the funnel, sort drop-off sessions by cart value descending, and watch the top five replays. That's a 15-minute weekly habit that pays for the tool by itself.