Interactive wizard to build and analyze conversion funnels from Mixpanel data
Interactive wizard to build and analyze conversion funnels from Mixpanel data. Use it to identify drop-off points and optimize user journeys.
/plugin marketplace add jaredmcfarland/mixpanel_data/plugin install mixpanel-data@mixpanel-datafunnel-idGuide the user through building and analyzing conversion funnels using saved Mixpanel funnels or custom event sequences.
Verify credentials are configured:
!$(mp auth test 2>&1 || echo "No credentials configured")
If credentials aren't configured, suggest running /mp-auth first.
Present two approaches:
Ask which approach the user prefers.
!$(mp inspect funnels --format table)
Show the user:
Tip: Use /mp-inspect to discover available events and cohorts for analysis context.
If $1 is provided, use that as funnel ID. Otherwise, ask user to choose from the list.
Date Range (required):
Time Unit (optional):
day (default)weekmonthSegmentation (optional):
country, plan, source)Basic funnel:
mp query funnel <funnel-id> \
--from <from-date> \
--to <to-date> \
--format table
With segmentation:
mp query funnel <funnel-id> \
--from <from-date> \
--to <to-date> \
--unit <day|week|month> \
--on <property> \
--format table
Show the user:
Key insights to highlight:
!$(mp inspect tables --format table)
If no tables exist, suggest running /mp-fetch first.
Ask the user for the event sequence (3-5 events recommended):
Table: Which table to analyze Time window: Maximum time between steps (e.g., 24 hours, 7 days) Date range: Filter events by date
Use a window function approach to detect sequences:
WITH user_events AS (
SELECT
distinct_id,
event_name,
event_time,
ROW_NUMBER() OVER (PARTITION BY distinct_id ORDER BY event_time) as event_seq
FROM <table>
WHERE event_name IN ('Step1', 'Step2', 'Step3', 'Step4')
AND event_time >= '<from-date>'
AND event_time <= '<to-date>'
),
funnel_progression AS (
SELECT
distinct_id,
MAX(CASE WHEN event_name = 'Step1' THEN 1 ELSE 0 END) as completed_step1,
MAX(CASE WHEN event_name = 'Step2' THEN 1 ELSE 0 END) as completed_step2,
MAX(CASE WHEN event_name = 'Step3' THEN 1 ELSE 0 END) as completed_step3,
MAX(CASE WHEN event_name = 'Step4' THEN 1 ELSE 0 END) as completed_step4
FROM user_events
GROUP BY distinct_id
)
SELECT
SUM(completed_step1) as step1_users,
SUM(completed_step2) as step2_users,
SUM(completed_step3) as step3_users,
SUM(completed_step4) as step4_users,
ROUND(100.0 * SUM(completed_step2) / NULLIF(SUM(completed_step1), 0), 2) as step1_to_step2_rate,
ROUND(100.0 * SUM(completed_step3) / NULLIF(SUM(completed_step2), 0), 2) as step2_to_step3_rate,
ROUND(100.0 * SUM(completed_step4) / NULLIF(SUM(completed_step3), 0), 2) as step3_to_step4_rate,
ROUND(100.0 * SUM(completed_step4) / NULLIF(SUM(completed_step1), 0), 2) as overall_conversion
FROM funnel_progression
Execute via:
mp query sql "<query>" --format table
Offer to create a Python visualization:
import pandas as pd
import matplotlib.pyplot as plt
# Data from query results
steps = ['Step1', 'Step2', 'Step3', 'Step4']
users = [<step1_users>, <step2_users>, <step3_users>, <step4_users>]
# Create funnel chart
fig, ax = plt.subplots(figsize=(10, 6))
ax.barh(steps, users, color=['#4CAF50', '#8BC34A', '#CDDC39', '#FFEB3B'])
ax.set_xlabel('Number of Users')
ax.set_title('Conversion Funnel')
# Add conversion rates
for i, (step, count) in enumerate(zip(steps, users)):
ax.text(count, i, f' {count:,} users', va='center')
plt.tight_layout()
plt.savefig('funnel.png')
print("Funnel visualization saved to funnel.png")
For local data, offer segmented funnel analysis:
Segment by property (e.g., country, plan, source):
WITH user_events AS (
SELECT
distinct_id,
event_name,
event_time,
properties->>'$.country' as country
FROM <table>
WHERE event_name IN ('Step1', 'Step2', 'Step3', 'Step4')
),
funnel_by_segment AS (
SELECT
country,
MAX(CASE WHEN event_name = 'Step1' THEN 1 ELSE 0 END) as completed_step1,
MAX(CASE WHEN event_name = 'Step2' THEN 1 ELSE 0 END) as completed_step2,
MAX(CASE WHEN event_name = 'Step3' THEN 1 ELSE 0 END) as completed_step3,
MAX(CASE WHEN event_name = 'Step4' THEN 1 ELSE 0 END) as completed_step4
FROM user_events
GROUP BY distinct_id, country
)
SELECT
country,
SUM(completed_step1) as step1_users,
ROUND(100.0 * SUM(completed_step4) / NULLIF(SUM(completed_step1), 0), 2) as conversion_rate
FROM funnel_by_segment
GROUP BY country
ORDER BY step1_users DESC
E-commerce Funnel:
SaaS Signup Funnel:
Content Engagement Funnel:
Mobile App Funnel:
After showing results, provide actionable insights:
If any step shows >50% drop-off:
⚠️ High drop-off detected at Step X → Step Y (Z% drop)
Recommendations:
- Investigate UX issues at Step X
- Add tracking for abandonment reasons
- A/B test simplified flow
- Check for technical errors
If segmented:
📊 Segment insights:
- Best performing: [Segment A] (X% conversion)
- Worst performing: [Segment B] (Y% conversion)
- Delta: Z percentage points
Recommendations:
- Study what makes [Segment A] successful
- Optimize experience for [Segment B]
- Consider separate funnels per segment
If using time units:
📈 Trend analysis:
- Conversion improving/declining over time
- Seasonal patterns detected
Recommendations:
- Investigate what changed during improvements
- Prepare for seasonal variations
After analysis, suggest:
Deep dive on specific step:
/mp-query sql
# Analyze users who dropped at specific step
Retention analysis:
/mp-retention
# Analyze retention for users who completed funnel
Export for presentation:
mp query funnel <id> --from <date> --to <date> --format csv > funnel_results.csv
Create custom report:
/mp-report funnel
# Generate comprehensive funnel report
"Funnel not found":
mp inspect funnels"No events found":
mp inspect events to see available events"Low sample size":
"Segmentation returns null":
mp inspect properties <event>defined(properties["prop"]) in filters