I’m running into a frustrating problem with my analytics setup. I have a Shopify store connected to Mixpanel for tracking customer behavior throughout their shopping experience.
I’ve set up tracking for four key events: when someone views a product, adds it to their cart, starts the checkout process, and finishes their order. Everything shows up correctly in the live data view, but there’s a major issue with user identification.
The problem is that Mixpanel seems to create a new distinct_id when customers complete their purchase. This means my funnel analysis is completely broken because it can’t connect the same user across all steps of their journey.
Here’s the tracking code I’m using in my checkout scripts:
mixpanel.track("Purchase Complete", {
"Order Value": "{{ order_total | money_without_currency }}"
});
mixpanel.identify({{ buyer.id }});
mixpanel.people.set({
"$name": "{{ buyer.first_name }} {{ buyer.last_name }}",
"$email": "{{ buyer.email }}",
"updated_at": new Date()
});
mixpanel.people.track_charge({{ order_total | money_without_currency }});
I’m using the same buyer.id across all my other tracking snippets in the theme files. Customers don’t create accounts, they just checkout as guests.
Has anyone solved this kind of user identification problem? I really need to see the complete customer journey and conversion rates in my funnels.
This drove me crazy for weeks until I figured out what was happening. Shopify’s guest checkout creates temporary session data that gets wiped when the order goes through. The buyer.id you’re tracking only exists at that final checkout moment, so all your earlier events are stuck with anonymous IDs that can’t be linked back later. I fixed my funnel tracking by building a custom session bridge with localStorage to keep one consistent identifier through the whole journey. Store a unique session ID when someone first lands on your product pages, then use that same ID for everything until checkout’s done. At purchase, alias that session ID to the buyer.id so Mixpanel can connect the dots. You need to maintain that identity thread before Shopify’s checkout creates the buyer record. Without this bridge, your pre-purchase events will always be orphaned from the conversion data.
Had this exact problem six months ago - nearly drove me insane! The issue is Shopify’s buyer.id only shows up after someone buys something. So your early tracking uses anonymous IDs, then boom - the purchase event gets a real user ID and Mixpanel can’t connect them. Here’s what worked: add mixpanel.alias({{ buyer.id }}) right before your mixpanel.identify() call in the checkout script. This links the anonymous session to the actual buyer ID. Also keep your mixpanel.identify() calls consistent across theme files - use buyer.id for logged-in customers, let it stay anonymous otherwise. The alias call when they go from anonymous to identified is what makes it work.
check if you’re using different tracking domains between your store pages and checkout - this breaks user sessions big time. Shopify Plus has this weird thing where checkout.shopify.com creates a totally separate tracking context. Try adding mixpanel.reset() before identify on checkout complete. sounds backwards but it helped me reconnect fragmented user paths last month.
Your tracking call timing is probably the issue. Had the same problem last year - Shopify’s checkout creates a new session that messes with Mixpanel’s user identification. Move your mixpanel.identify() call before the track event, not after. Always identify first, then track the purchase. Also check you’re using the same distinct_id format everywhere - Shopify sometimes passes buyer.id as a string, sometimes as an integer. Mixpanel sees these as different users. I wrap all my buyer.id calls with toString() to keep it consistent. Make sure your product view and cart tracking fire on the same domain as checkout completion too - cross-domain issues can fragment user journeys.
This topic was automatically closed 4 days after the last reply. New replies are no longer allowed.