Funnel Conversion Analysis With SQL
Constructs a stepwise conversion funnel with drop-off rates and time-to-convert from event data.
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.
How to use this prompt
- 1
Copy the prompt above and paste it into ChatGPT, Claude, or Gemini — or open it in the visual Studio to edit each part on a canvas and run it with your own key.
- 2
Replace any bracketed placeholders with your specifics. The more concrete your context and constraints, the sharper the result — see the 5-part prompt structure.
- 3
Run it, then refine. Ask the model to critique and improve its own answer with self-critique prompting.
Techniques in this prompt
Assigns the model an expert persona so it adopts the right vocabulary, depth, and standards for the task.
Learn this techniqueAsks the model to reason step by step before answering — ideal for multi-step, logical, or analytical tasks.
Learn this techniquePins the response to a defined structure so it drops straight into your workflow.
Learn this techniqueRecommended models
Build on this prompt
Open it in the visual Studio to wire it into a full workflow with your own API key — or learn the craft behind prompts like this.
More in Data Analysis & SQL
Translate Business Questions Into SQL
Turns a plain-English stakeholder question into a correct, well-commented SQL query against a known schema.
Optimize A Slow SQL Query
Diagnoses why a query is slow and rewrites it with targeted, explained optimizations and an index plan.
Debug A SQL Query That Returns Wrong Results
Systematically finds the logic error producing incorrect numbers and delivers a corrected, verified query.
Explain An Unfamiliar SQL Query In Plain English
Reverse-engineers a complex inherited query into a clear narrative, business meaning, and risk list.