Situation: We need a rapid, actionable diagnostic funnel to locate where purchases from Product Detail Pages (PDP) are leaking.Funnel steps & specific events1. PDP View — event: product_view (product_id, user_id, session_id, timestamp)2. Add to Cart — event: add_to_cart (product_id, user_id, session_id, timestamp, qty)3. Cart View / Mini-cart Open — event: cart_view (session_id, timestamp)4. Begin Checkout — event: checkout_start (session_id, user_id, timestamp)5. Payment Initiated — event: payment_init (order_id, session_id, timestamp, payment_method)6. Purchase Confirmed — event: purchase (order_id, session_id, user_id, total, timestamp)Recommended diagnostic metrics (for each adjacent step)- Step conversion rate = users who completed step N+1 / users who completed step N- Absolute leakage = count(N) - count(N+1)- Relative drop = % change vs baseline period (week-over-week, 28d)- Median & 90th percentile time_between_steps (timestamp difference)- Error / failure rates: payment failures, API error codes, validation errors- Device/session-quality signals: bounce rate, page load time, JS errorsQueries / slices to identify largest leak1. Compute funnel conversion and drop by step (weekly):sql
WITH step_counts AS (
SELECT
date_trunc('day', timestamp) as day,
COUNT(DISTINCT CASE WHEN event='product_view' THEN session_id END) AS views,
COUNT(DISTINCT CASE WHEN event='add_to_cart' THEN session_id END) AS adds,
COUNT(DISTINCT CASE WHEN event='cart_view' THEN session_id END) AS cart_views,
COUNT(DISTINCT CASE WHEN event='checkout_start' THEN session_id END) AS checkouts,
COUNT(DISTINCT CASE WHEN event='payment_init' THEN session_id END) AS payments,
COUNT(DISTINCT CASE WHEN event='purchase' THEN order_id END) AS purchases
FROM events
WHERE product_id = :product_id AND timestamp BETWEEN :start AND :end
GROUP BY day
)
SELECT day,
views,
adds, adds::float/views as conv_view_add,
cart_views, cart_views::float/adds as conv_add_cart,
checkouts, checkouts::float/cart_views as conv_cart_checkout,
payments, payments::float/checkouts as conv_checkout_payment,
purchases, purchases::float/payments as conv_payment_purchase
FROM step_counts
ORDER BY day;
2. Rank steps by leakage:sql
SELECT step,
count_before, count_after,
(count_before - count_after) AS absolute_leak,
(1 - count_after::float/count_before) AS leak_pct
FROM (
VALUES
('view->add', views, adds),
('add->cart', adds, cart_views),
('cart->checkout', cart_views, checkouts),
('checkout->payment', checkouts, payments),
('payment->purchase', payments, purchases)
) t(step, count_before, count_after)
ORDER BY absolute_leak DESC;
3. Slice the worst step by dimensions:- Device type, browser, OS_version, country, channel, product_variant, A/B cohort:sql
SELECT device_type, browser, count_before, count_after,
(1 - count_after::float/count_before) as leak_pct
FROM per_device_counts
WHERE step = 'view->add'
ORDER BY leak_pct DESC LIMIT 20;
4. Time and error diagnostics on that step:- Histogram of time_between_steps; join to logs for JS errors, network failures, 5xx responses, payment decline codes.Suggested monitoring thresholds (alerts)- Step conversion drops >20% week-over-week OR >10 percentage points absolute vs baseline — Page-level alert- Absolute purchases drop >15% vs 7-day moving average — Business alert- Payment failure rate >1% (or 2x baseline) — Critical alert- Median time_between_steps increases >100% (or >30s) — Performance alert- JS error rate >0.5% of PDP sessions — Engineering alert- Browser-specific conversion drop >30% for >1% of traffic — Investigate regressionsInvestigation priority1. Identify step with largest absolute leak and steepest relative drop.2. Slice by device/browser/channel and surface common denominators.3. Correlate with deploy/release timestamps, CDN errors, API error spikes, frontend JS error spikes, and backend latency.4. Reproduce: simulate user flow on worst device/browser, inspect console/network, and check A/B flags.This approach yields a fast path to isolate the leak, prioritize fixes (frontend issue, backend/API, payment gateway, or UX), and set thresholds to detect regressions proactively.