Mixpanel Product Analytics Certification study materials
Mixpanel Product Analytics Certification study resources

SPA Migration Breaks Pageviews and Campaign Attribution

Mixpanel Product Analytics Certification · Put your knowledge to work in context.

All case studies

SPA Migration Breaks Pageviews and Campaign Attribution

Harbor & Pine is a direct-to-consumer home goods retailer. It migrated its storefront from server-rendered pages to a single-page React app eight weeks ago. Before migration, the site averaged 180,000 sessions per month and a 2.8% purchase conversion rate. After migration, Mixpanel reports 1.9% conversion and 35% fewer pageview events, while the warehouse order table shows roughly flat orders. Paid social sessions show a 72% bounce rate on the landing page, but session replays show many of those users scrolling to product tiles and opening quick-view modals. About 40% of paid sessions have no UTM parameters in Mixpanel, although ad platform reports show normal clicks. Engineering says routes update via history.pushState and the pageview call sits in a useEffect with an empty dependency array. A short-link redirect service also strips query strings on some campaigns. Marketing wants to pause paid social.

1. Is the conversion decline more likely real or a measurement artifact? What single query would you run first, and what would it tell you?

Read the worked answer

The warehouse orders being flat while Mixpanel conversion falls is strong evidence of a measurement problem, but the first query should isolate numerator from denominator. Join daily Mixpanel purchase event counts to warehouse orders by date and campaign. If purchase counts match orders, the purchase event is intact and the reported conversion is being distorted by the denominator: sessions or pageviews are undercounted, or the funnel step used as the denominator is stale. If purchase counts are also below warehouse orders, the purchase tracking itself is broken. Only after that should you inspect session counts and pageview coverage. Do not pause paid social until this is resolved, because the 72% bounce rate is also suspect: in a single-page app, a user who lands once and browses several product views can look like a single-page bounce if route changes never emit pageviews.

2. How would you repair pageview and UTM capture without a full rewrite, and how would you validate the fix end-to-end?

Read the worked answer

Add a central route-change listener rather than relying on a component mount. Subscribe to the router or patch history.pushState and replaceState, plus popstate, and call track('pageview') on every route change with the current path, referrer, and full URL. Ensure the effect depends on location so it does not run only once. For UTMs, capture campaign parameters on first landing and persist them in a cookie or local storage before any redirect; also fix the short-link service so it forwards the query string or appends the same parameters server-side. Attach the stored values to the user or session and include them on subsequent events. Validate with a tagged test link on staging: confirm one pageview per route transition, no duplicate initial pageview, the correct $current_url, and UTMs present on both the landing event and a later purchase event. Then compare daily pageview counts against server access logs for a week.