Build a Strictly Ordered Google Shopping Checkout Funnel in SQL

Last updated: November 29, 2026

Quick Overview

From Google Shopping event logs, count users who viewed a product, then added to cart, then began checkout, then purchased, where each step must happen after the previous one, and report step-to-step conversion.

Google
Data Manipulation (SQL/Python)
Data Scientist
Google
November 29, 2026
Data Scientist
Technical Screen
Data Manipulation (SQL/Python)
Medium

0

0

0 solved


From Google Shopping event logs, count users who viewed a product, then added to cart, then began checkout, then purchased, where each step must happen after the previous one, and report step-to-step conversion.

Funnel questions are common in Google product analytics screens. The twist here is order: a user who added to cart from a saved list before ever viewing a product page should not count as converting from view. The interviewer checks that you chain timestamps instead of just counting distinct users per event type.

What the Interviewer Expects
  • Explain why counting distinct users per event overstates the funnel
  • Take the first qualifying timestamp at each step after the previous step's time
  • Chain steps with joins on user and a timestamp inequality
  • Report both percent of top and step conversion
  • Discuss session or time-bounded variants
Key Topics to Cover
funnel analysis
ordered events
self join
conversion rates
How to Approach This
  1. Clarify the schema and expected output format before writing queries.
  2. Use CTEs (WITH clauses) to break complex queries into readable steps.
  3. Consider window functions (ROW_NUMBER, RANK, LAG, LEAD) for ranking and sequential analysis.
  4. Watch for NULLs, duplicates, and edge cases in JOINs and GROUP BY.
  5. For pandas, prefer vectorized operations over row-by-row iteration.
Possible Follow-up Questions
  • How would you require all steps to happen within 24 hours of the view?
  • How would you build the same funnel per session instead of per user?
  • Events can arrive out of order from mobile clients. How does that affect the funnel?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice SQL Problems
Sample Answer
Clarify the Data

shopping_events(user_id, event_ts, event_name, product_id) for one week. Steps: view_product, add_to_cart, begin_checkout, purchase. Funnel is per user, not per product, and a later step onl...

Approach

Step 1 is each user's first view. Step 2 is the first add to cart strictly after that view. Each later step uses the previous step's timestamp as the lower bound. Using the earliest qualifying time at...


Submit Your Answer
Markdown supported