Shopify is the platform where I see the biggest gap between what store owners think they’re tracking and what’s actually in Mixpanel.
The usual story: someone pasted the Mixpanel snippet into the theme, saw page views arrive, and assumed purchases were tracked too. They weren’t. Shopify’s checkout doesn’t run your theme’s scripts, so the most important event in the store never reached Mixpanel.
This guide shows how to track the full Shopify funnel in Mixpanel, from product views to completed checkout, using the approach Mixpanel documents: the JavaScript SDK on the storefront plus Shopify’s Web Pixel API (Customer Events) for checkout.
Why Shopify needs a special approach
Mixpanel’s docs put it plainly: Shopify’s checkout is strict about only running approved scripts. Code in your theme doesn’t run there. To capture checkout and purchase events, you use Shopify’s Customer Events feature, which lets you add a custom pixel that subscribes to standard events Shopify emits, including at checkout.
You have three main options:
| Option | Effort | Best for |
|---|---|---|
| SDK + autocapture in the theme | Low | Browsing behavior only (no checkout) |
| SDK + Shopify Web Pixel (custom pixel) | Medium | Full funnel with your own event design |
| A no-code app (Mixpanel’s docs mention Vendo) | Low | Teams who don’t want to maintain code |
This guide focuses on option 2, which is what I recommend for most stores.
Step 1: Plan your ecommerce events
Before writing code, decide your event names and properties (post 4). A solid Shopify set, mapped to Shopify’s standard customer events:
| Mixpanel event | Shopify customer event | Key properties |
|---|---|---|
product_viewed | product_viewed | product_id, title, variant, price, currency |
collection_viewed | collection_viewed | collection_id, title |
search_submitted | search_submitted | search_query |
product_added_to_cart | product_added_to_cart | product_id, quantity, price, currency |
checkout_started | checkout_started | cart value, item_count, currency |
checkout_shipping_submitted | checkout_shipping_info_submitted | shipping method |
payment_info_submitted | payment_info_submitted | (step marker) |
checkout_completed | checkout_completed | order_id, value, currency, items, discount |
Check Shopify’s Web Pixel standard events reference for the exact event names and data available; Shopify maintains the complete list.
Tracking each checkout step separately is worth it. Instead of “checkout conversion dropped,” you’ll know exactly which step lost people.
Step 2: Install the SDK in your theme (storefront behavior)
For browsing behavior, add the Mixpanel SDK to the theme, as Mixpanel’s Shopify guide describes:
- In Shopify admin, go to Online Store → Themes → Edit code.
- Open
theme.liquid. - Paste the Mixpanel snippet and your
mixpanel.init()call just before the closing</head>tag. - Optionally enable autocapture (post 24) for clicks and scroll depth.
If you’d rather keep all your tracking in one place, you can push Shopify events into a dataLayer and send them to Mixpanel through GTM instead (post 22). Either way, keep one source of truth.
Step 3: Create a custom pixel for checkout
- In Shopify admin, go to Settings → Customer events.
- Click Add custom pixel and give it a clear name, for example “Mixpanel”.
- Set the customer privacy permissions to match your consent setup.
Step 4: Write the pixel code
Mixpanel’s guide describes the pixel code as three parts: subscribe to Shopify’s event API, load the Mixpanel SDK, then initialize and track. Here’s a cleaner structure I use, which loads the SDK once rather than inside every subscription:
// 1. Load the Mixpanel SDK (paste Mixpanel's snippet here, without <script> tags)
// 2. Initialize once
mixpanel.init('YOUR_PROJECT_TOKEN', {
persistence: 'localStorage'
});
// 3. Product viewed
analytics.subscribe('product_viewed', (event) => {
const v = event.data.productVariant;
mixpanel.track('product_viewed', {
product_id: v.product.id,
product_title: v.product.title,
variant_id: v.id,
price: v.price.amount,
currency: v.price.currencyCode,
shopify_client_id: event.clientId
});
});
// 4. Checkout completed
analytics.subscribe('checkout_completed', (event) => {
const checkout = event.data.checkout;
mixpanel.track('checkout_completed', {
order_id: checkout.order.id,
value: checkout.totalPrice.amount,
currency: checkout.currencyCode,
item_count: checkout.lineItems.length,
items: checkout.lineItems.map((item) => ({
product_id: item.variant.product.id,
title: item.variant.product.title,
quantity: item.quantity,
price: item.variant.price.amount,
sku: item.variant.sku
})),
shopify_client_id: event.clientId,
$insert_id: 'order_' + checkout.order.id
});
});
Verify field paths against Shopify’s current Web Pixel event reference before going live; Shopify’s data structure is the source of truth. The $insert_id based on the order ID protects you from duplicate purchases if the event fires twice (post 3).
Add subscriptions for the other events in your plan the same way..
Step 5: Handle identity
This is the subtle part of Shopify tracking. Custom pixels run in a sandboxed environment, separate from your theme, so don’t assume the pixel automatically shares the same Mixpanel anonymous ID as the storefront SDK. Test it.
What I do:
- Send Shopify’s
clientIdas a property on every pixel event (as above), and ideally on storefront events too, so you can connect sessions. - When a customer is logged in, identify them with a stable customer ID, not an email.
- If identity across theme and pixel matters a lot to you, consider sending all events through one path, such as the pixel or a server-side setup, rather than mixing.
Post 2 explains how Mixpanel merges identities.
Step 6: Test and connect the pixel
- In the custom pixel editor, use Shopify’s Test option to confirm the pixel connects.
- Connect the pixel to make it live.
- Visit your storefront, view a product, add to cart, and place a test order (use Shopify’s test payment mode).
- In Mixpanel’s Events view, confirm each event arrives with its properties.
Step 7: Build your Shopify funnel
In Mixpanel, build a funnel (post 9):
product_viewed → product_added_to_cart → checkout_started → checkout_shipping_submitted → payment_info_submitted → checkout_completed
Set a conversion window that suits your buying cycle, and break down by UTM source and device. Then sum value on checkout_completed in Insights for revenue (post 26 covers revenue properly).
Going further: server-side orders
Browser pixels can still be affected by blockers and don’t see refunds, cancellations or subscription renewals. For complete revenue data, many of my clients add server-side order events from Shopify webhooks or a server-side GTM setup (post 23), with the same order-based $insert_id to avoid duplicates.
Mistakes to avoid
- Assuming theme code tracks checkout. It doesn’t.
- Loading the SDK inside every subscription, which repeats work for each event.
- Tracking purchases from the thank-you page in the theme instead of the pixel’s
checkout_completed. - Missing currency on value properties, which breaks multi-currency stores.
- No
$insert_idon purchases. - Not testing identity between theme and pixel.
Final thoughts
Shopify gives you a reliable, supported way to capture checkout events. Use the theme for browsing behavior, the custom pixel for checkout, consistent names across both, and order-based deduplication. That gives you a full funnel you can trust.
Sources
- Mixpanel: Shopify integration guide
- Mixpanel: CMS and e-commerce integrations
- Shopify: Web Pixels API, custom pixels
- Shopify: Web Pixels standard events
- Mixpanel: Event Deduplication
