Ordered LIVE Gifting Funnel Per Viewer and Room

Last updated: November 29, 2026

Quick Overview

From an event log of LIVE room activity (enter_room, open_gift_panel, send_gift), compute per room how many viewers entered, opened the gift panel after entering, and sent a gift within 30 minutes of opening the panel, with step conversion rates.

TikTok
Data Manipulation (SQL/Python)
Data Scientist
TikTok
November 29, 2026
Data Scientist
Onsite
Data Manipulation (SQL/Python)
Hard

0

0

0 solved


From an event log of LIVE room activity (enter_room, open_gift_panel, send_gift), compute per room how many viewers entered, opened the gift panel after entering, and sent a gift within 30 minutes of opening the panel, with step conversion rates.

TikTok LIVE monetizes largely through virtual gifts, so the monetization analytics team cares about where viewers drop between entering a room and gifting. The interviewer checks strict step ordering, a time bound on the final step, and that out-of-order events do not inflate conversion.

What the Interviewer Expects
  • Enforce step order: each step must occur after the previous step's timestamp
  • Apply the 30-minute bound only to the panel-to-gift step
  • Use LEFT JOINs so drop-offs stay in the denominator
  • Count distinct viewer-room pairs rather than events
  • Guard against division by zero in rooms with no panel opens
Key Topics to Cover
funnel analysis
ordered events
conditional joins
LIVE gifting
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 handle a viewer who leaves and re-enters the room several times?
  • How would you compute median time from panel open to gift?
  • Gift conversion fell after a panel redesign. How would you check whether it is real or a logging change?
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

live_events(user_id, room_id, event_type, event_ts) with types enter_room, open_gift_panel, send_gift.

  • Unit of the funnel: a (user_id, room_id) pair.
  • Anchor on the first enter_room. T...
Approach

Build the funnel step by step, each step a LEFT JOIN constrained on the previous step's timestamp, taking MIN to get the first qualifying event. Then aggregate per room with COUNT(col), which igno...


Submit Your Answer
Markdown supported