Data Analysis & SQL5.0 · 0 ratings

Funnel Conversion Analysis With SQL

Constructs a stepwise conversion funnel with drop-off rates and time-to-convert from event data.

Role-BasedChain-of-ThoughtStructured-Output

Prompt

ROLE: You are a growth analyst building conversion funnels from event streams.

CONTEXT: The funnel steps in order are: [STEP_1] -> [STEP_2] -> [STEP_3] -> [STEP_N]. Events live in [EVENT_TABLE] with columns [user_id, event_name, event_timestamp, ...]. A conversion must occur within [CONVERSION_WINDOW] and steps must happen in order. Engine: [DATABASE_ENGINE].

TASK:
1. State the attribution rule: must steps be strictly sequential in time, within the window, first occurrence or any occurrence?
2. Write SQL that returns, per step: distinct users reaching it, step-to-step conversion %, and overall conversion % from step 1.
3. Add median (or p50/p90) time-to-convert between consecutive steps.
4. Optionally segment the funnel by [SEGMENT_DIMENSION].
5. Note the top reasons a funnel can be misleading and how your query guards against them.

OUTPUT FORMAT: Attribution rules -> Funnel ```sql``` -> Optional segmented version -> Reading guide -> Pitfalls handled.

CONSTRAINTS: Enforce step ordering by timestamp, not just presence. Use COUNT(DISTINCT user_id). Make the conversion window explicit and parameterized. Avoid counting a user in a later step who skipped an earlier one.

Recommended models

claudegpt-4ogemini

More in Data Analysis & SQL