1
---
2
name: Funnel Analysis
3
description: Analyze user conversion funnels, identify drop-off points, and optimize conversion rates for conversion optimization and user flow analysis
4
---
5
6
# Funnel Analysis
7
8
## Overview
9
10
Funnel analysis tracks user progression through sequential steps, identifying where users drop off and optimizing each stage for better conversion.
11
12
## When to Use
13
14
- When optimizing user conversion paths and improving conversion rates
15
- When identifying bottlenecks and drop-off points in user flows
16
- When comparing performance across different segments or traffic sources
17
- When measuring product feature adoption or onboarding effectiveness
18
- When improving customer journey efficiency and user experience
19
- When A/B testing different funnel configurations or designs
20
21
## Funnel Structure
22
23
- **Stage 1**: Initial entry (landing page, app open)
24
- **Stage 2-N**: Intermediate steps (signup, selection, payment)
25
- **Final Stage**: Goal completion (purchase, subscription, sign-up)
26
- **Drop-off**: Users not progressing to next stage
27
- **Conversion Rate**: % progressing to next step
28
29
## Key Metrics
30
31
- **Drop-off Rate**: % leaving at each stage
32
- **Conversion Rate**: % progressing per stage
33
- **Funnel Efficiency**: Overall conversion (Stage 1 to Final)
34
- **Friction Score**: Identifying problem areas
35
36
## Implementation with Python
37
38
```python
39
import pandas as pd
40
import numpy as np
41
import matplotlib.pyplot as plt
42
import seaborn as sns
43
44
# Create sample funnel data
45
np.random.seed(42)
46
47
funnel_stages = ['Landing Page', 'Sign Up', 'Product Selection', 'Add to Cart', 'Checkout', 'Payment', 'Confirmation']
48
49
# Simulate user journey (progressive drop-off)
50
data = []
51
users_at_stage = 100000
52
for i, stage in enumerate(funnel_stages):
53
# Progressively lower retention
54
drop_off_rate = 0.15 + (i * 0.05) # Increasing drop-off
55
users_at_stage = int(users_at_stage * (1 - drop_off_rate))
56
57
for _ in range(users_at_stage):
58
data.append({
59
'user_id': f'user_{np.random.randint(0, 1000000)}',
60
'stage': stage,
61
'timestamp': np.random.randint(0, 365),
62
})
63
64
df = pd.DataFrame(data)
65
66
# 1. Funnel Counts
67
funnel_counts = df['stage'].value_counts().reindex(funnel_stages)
68
print("Funnel Counts by Stage:")
69
print(funnel_counts)
70
71
# 2. Funnel Metrics
72
funnel_metrics = pd.DataFrame({
73
'Stage': funnel_stages,
74
'Users': funnel_counts.values,
75
})
76
77
funnel_metrics['Drop-off'] = funnel_metrics['Users'].shift(1) - funnel_metrics['Users']
78
funnel_metrics['Drop-off %'] = (funnel_metrics['Drop-off'] / funnel_metrics['Users'].shift(1) * 100).round(2)
79
funnel_metrics['Conversion %'] = (funnel_metrics['Users'] / funnel_metrics['Users'].iloc[0] * 100).round(2)
80
81
print("\nFunnel Metrics:")
82
print(funnel_metrics)
83
84
# 3. Visualization - Funnel Chart
85
fig, axes = plt.subplots(1, 2, figsize=(14, 6))
86
87
# Traditional funnel visualization
88
ax = axes[0]
89
colors = plt.cm.RdYlGn_r(np.linspace(0.3, 0.7, len(funnel_metrics)))
90
91
for idx, (stage, users) in enumerate(zip(funnel_metrics['Stage'], funnel_metrics['Users'])):
92
# Create trapezoid-like bars
93
width = users / funnel_metrics['Users'].max()
94
y_pos = len(funnel_metrics) - idx - 1
95
ax.barh(y_pos, width, left=(1 - width) / 2, height=0.6, color=colors[idx], edgecolor='black')
96
ax.text(-0.05, y_pos, stage, ha='right', va='center', fontsize=10)
97
ax.text(0.5, y_pos, f"{users:,}", ha='center', va='center', fontsize=9, fontweight='bold')
98
99
ax.set_xlim(0, 1)
100
ax.set_ylim(-0.5, len(funnel_metrics) - 0.5)
101
ax.set_xticks([])
102
ax.set_yticks([])
103
ax.set_title('Conversion Funnel')
104
105
# Step-by-step conversion
106
ax2 = axes[1]
107
x_pos = np.arange(len(funnel_stages))
108
colors2 = plt.cm.Spectral(np.linspace(0, 1, len(funnel_stages)))
109
110
bars = ax2.bar(x_pos, funnel_metrics['Users'], color=colors2, edgecolor='black', alpha=0.7)
111
112
# Add value labels
113
for i, (bar, users, conv) in enumerate(zip(bars, funnel_metrics['Users'], funnel_metrics['Conversion %'])):
114
height = bar.get_height()
115
ax2.text(bar.get_x() + bar.get_width() / 2., height,
116
f'{int(users):,}\n({conv:.1f}%)',
117
ha='center', va='bottom', fontsize=9)
118
119
ax2.set_ylabel('User Count')
120
ax2.set_title('Users by Stage')
121
ax2.set_xticks(x_pos)
122
ax2.set_xticklabels(funnel_stages, rotation=45, ha='right')
123
ax2.grid(True, alpha=0.3, axis='y')
124
125
plt.tight_layout()
126
plt.show()
127
128
# 4. Drop-off Analysis
129
fig, ax = plt.subplots(figsize=(12, 6))
130
131
# Filter out first stage (no drop-off from before)
132
drop_off_data = funnel_metrics[1:].copy()
133
drop_off_data = drop_off_data[drop_off_data['Drop-off'] > 0]
134
135
colors_drop = ['#d62728' if x > drop_off_data['Drop-off'].median() else '#2ca02c'
136
for x in drop_off_data['Drop-off']]
137
138
bars = ax.barh(drop_off_data['Stage'], drop_off_data['Drop-off %'], color=colors_drop, edgecolor='black')
139
140
# Add value labels
141
for i, (bar, drop_pct) in enumerate(zip(bars, drop_off_data['Drop-off %'])):
142
width = bar.get_width()
143
ax.text(width, bar.get_y() + bar.get_height() / 2.,
144
f'{drop_pct:.1f}%',
145
ha='left', va='center', fontsize=10, fontweight='bold')
146
147
ax.set_xlabel('Drop-off Rate (%)')
148
ax.set_title('Drop-off Rates by Stage')
149
ax.grid(True, alpha=0.3, axis='x')
150
151
plt.tight_layout()
152
plt.show()
153
154
# 5. Funnel Efficiency Matrix
155
efficiency_matrix = funnel_metrics[['Stage', 'Conversion %']].copy()
156
print("\nFunnel Efficiency (% of Initial Users):")
157
print(efficiency_matrix)
158
159
# 6. Stage-to-stage conversion
160
fig, ax = plt.subplots(figsize=(12, 6))
161
162
stage_conversion = []
163
for i in range(len(funnel_metrics) - 1):
164
conversion = (funnel_metrics.iloc[i + 1]['Users'] / funnel_metrics.iloc[i]['Users'] * 100)
165
stage_conversion.append({
166
'Transition': f"{funnel_metrics.iloc[i]['Stage']}\n→ {funnel_metrics.iloc[i+1]['Stage']}",
167
'Conversion %': conversion
168
})
169
170
stage_conv_df = pd.DataFrame(stage_conversion)
171
colors_stage = ['#2ca02c' if x > 80 else '#ff7f0e' if x > 60 else '#d62728'
172
for x in stage_conv_df['Conversion %']]
173
174
bars = ax.bar(range(len(stage_conv_df)), stage_conv_df['Conversion %'], color=colors_stage, edgecolor='black')
175
176
# Add value labels
177
for bar, conv in zip(bars, stage_conv_df['Conversion %']):
178
height = bar.get_height()
179
ax.text(bar.get_x() + bar.get_width() / 2., height,
180
f'{conv:.1f}%',
181
ha='center', va='bottom', fontsize=10, fontweight='bold')
182
183
ax.set_ylabel('Conversion Rate (%)')
184
ax.set_title('Stage-to-Stage Conversion Rates')
185
ax.set_xticks(range(len(stage_conv_df)))
186
ax.set_xticklabels(stage_conv_df['Transition'], fontsize=9)
187
ax.set_ylim([0, 105])
188
ax.axhline(y=80, color='green', linestyle='--', alpha=0.5, label='Good (80%+)')
189
ax.axhline(y=60, color='orange', linestyle='--', alpha=0.5, label='Acceptable (60%+)')
190
ax.legend()
191
ax.grid(True, alpha=0.3, axis='y')
192
193
plt.tight_layout()
194
plt.show()
195
196
# 7. Funnel by Segment (e.g., traffic source)
197
np.random.seed(42)
198
df['traffic_source'] = np.random.choice(['Organic', 'Paid', 'Direct'], len(df))
199
200
# Create funnel for each segment
201
fig, axes = plt.subplots(1, 3, figsize=(15, 6))
202
203
for idx, source in enumerate(['Organic', 'Paid', 'Direct']):
204
df_segment = df[df['traffic_source'] == source]
205
segment_counts = df_segment['stage'].value_counts().reindex(funnel_stages)
206
207
segment_metrics = pd.DataFrame({
208
'Stage': funnel_stages,
209
'Users': segment_counts.values,
210
})
211
segment_metrics['Conversion %'] = (segment_metrics['Users'] / segment_metrics['Users'].iloc[0] * 100).round(2)
212
213
ax = axes[idx]
214
x_pos = np.arange(len(funnel_stages))
215
bars = ax.bar(x_pos, segment_metrics['Users'], color='steelblue', edgecolor='black', alpha=0.7)
216
217
for bar, conv in zip(bars, segment_metrics['Conversion %']):
218
height = bar.get_height()
219
ax.text(bar.get_x() + bar.get_width() / 2., height,
220
f'{conv:.1f}%',
221
ha='center', va='bottom', fontsize=8)
222
223
ax.set_title(f'Funnel: {source}')
224
ax.set_ylabel('Users')
225
ax.set_xticks(x_pos)
226
ax.set_xticklabels(funnel_stages, rotation=45, ha='right', fontsize=8)
227
ax.grid(True, alpha=0.3, axis='y')
228
229
plt.tight_layout()
230
plt.show()
231
232
# 8. Comparison table of segments
233
print("\nFunnel Comparison by Traffic Source:")
234
comparison_data = []
235
for source in ['Organic', 'Paid', 'Direct']:
236
df_segment = df[df['traffic_source'] == source]
237
segment_counts = df_segment['stage'].value_counts().reindex(funnel_stages)
238
comparison_data.append({
239
'Traffic Source': source,
240
'Landing': segment_counts.iloc[0],
241
'Sign Up': segment_counts.iloc[1],
242
'Product': segment_counts.iloc[2],
243
'Cart': segment_counts.iloc[3],
244
'Final Conv %': (segment_counts.iloc[-1] / segment_counts.iloc[0] * 100),
245
})
246
247
comparison_df = pd.DataFrame(comparison_data)
248
print(comparison_df.round(2))
249
250
# 9. Sankey diagram representation (text-based)
251
print("\nFunnel Flow Summary:")
252
print("="*60)
253
for i in range(len(funnel_metrics) - 1):
254
current = funnel_metrics.iloc[i]
255
next_stage = funnel_metrics.iloc[i + 1]
256
drop = current['Users'] - next_stage['Users']
257
conv_pct = (next_stage['Users'] / current['Users'] * 100)
258
259
print(f"{current['Stage']}")
260
print(f" ├─ Continue: {next_stage['Users']:>7,} ({conv_pct:>5.1f}%)")
261
print(f" └─ Drop-off: {drop:>7,} ({100-conv_pct:>5.1f}%)")
262
print(f"\n{funnel_metrics.iloc[-1]['Stage']}")
263
print(" └─ Completed: {0:,}".format(int(funnel_metrics.iloc[-1]['Users'])))
264
265
# 10. Key insights visualization
266
fig, ax = plt.subplots(figsize=(10, 6))
267
ax.axis('off')
268
269
insights = f"""
270
FUNNEL ANALYSIS SUMMARY
271
272
Total Users: {int(funnel_metrics['Users'].iloc[0]):,}
273
Conversions: {int(funnel_metrics['Users'].iloc[-1]):,}
274
Overall Conversion Rate: {funnel_metrics['Conversion %'].iloc[-1]:.2f}%
275
276
BOTTLENECKS (Highest Drop-off):
277
1. {funnel_metrics[funnel_metrics['Drop-off %'].idxmax()]['Stage']} - {funnel_metrics['Drop-off %'].max():.1f}%
278
2. {funnel_metrics[funnel_metrics['Drop-off %'].nlargest(2).index[1]]['Stage']}
279
280
BEST PERFORMERS (Highest Conversion):
281
1. {stage_conv_df.nlargest(2, 'Conversion %').iloc[0]['Transition'].split(chr(10))[1][2:]} - {stage_conv_df['Conversion %'].nlargest(2).iloc[0]:.1f}%
282
2. {stage_conv_df.nlargest(2, 'Conversion %').iloc[1]['Transition'].split(chr(10))[1][2:]} - {stage_conv_df['Conversion %'].nlargest(2).iloc[1]:.1f}%
283
284
RECOMMENDATIONS:
285
• Focus optimization on highest drop-off stages
286
• Benchmark against industry standards
287
• A/B test improvements at each stage
288
• Monitor segment performance separately
289
"""
290
291
ax.text(0.05, 0.95, insights, transform=ax.transAxes, fontfamily='monospace',
292
fontsize=11, verticalalignment='top', bbox=dict(boxstyle='round', facecolor='wheat', alpha=0.5))
293
294
plt.tight_layout()
295
plt.show()
296
```
297
298
## Funnel Analysis Steps
299
300
1. Define all stages in customer journey
301
2. Count users at each stage
302
3. Calculate drop-off and conversion rates
303
4. Identify biggest bottlenecks
304
5. Analyze by segments (traffic source, device, etc.)
305
6. Benchmark against goals
306
7. Prioritize optimization efforts
307
308
## Common Drop-off Points
309
310
- Complex signup forms
311
- Unexpected fees
312
- Confusing navigation
313
- Payment issues
314
- Technical errors
315
316
## Deliverables
317
318
- Funnel visualization chart
319
- Drop-off analysis table
320
- Stage-to-stage conversion rates
321
- Segmented funnel analysis
322
- Bottleneck identification
323
- Actionable optimization recommendations
324
- Benchmark comparison report
325