The Shopper Path to Payment

The Shopper Path to Payment

You analyze a marketplace for independent local brands. Before a major acquisition campaign, the growth team wants a basic multi-step funnel by traffic source: product view, cart open, checkout start, and payment. For each shopper, take the earliest non-null timestamp for each of these event types: product_viewed, cart_opened, checkout_started, and order_paid. A shopper reaches a later stage only when those first-achievement timestamps are in non-decreasing order. Adjacent stages may share the same timestamp. For example, when the earliest cart open happened before the earliest product view, the shopper does not reach the cart stage even if another cart event occurred later. Include every source found in marketplace_shoppers, including sources with no product views. Display a NULL traffic_source as unknown. Return columns: - source — traffic source, text. - viewed_users — shoppers who reached the view stage, integer. - cart_users — shoppers who reached the cart stage after the view under the rules above, integer. - checkout_users — shoppers who reached checkout after the cart stage, integer. - paid_users — shoppers who reached payment after checkout, integer. - view_to_paid_pct — paid shoppers as a percentage of viewed shoppers, numeric, rounded to 2 decimal places. Return 0.00 when there are no viewed shoppers. Sort by source ascending. Ignore events whose event_time is NULL. Repeated events of the same type must not inflate counts.

Expected output sample

This is what a correct answer looks like — its row count is its own, it doesn't have to match the schema tables. Your answer must use the same column names as this sample — alias them with AS if needed.

sourceviewed_userscart_userscheckout_userspaid_usersview_to_paid_pct
affiliate21100
direct00000
email11100
PostgreSQLv16

Your query result will appear here

Focus radio
Paused · SomaFM · Fluid