Funnel Analysis: Measuring Conversion Step by Step
Funnel analysis step by step on 12,330 real shopping sessions: defining the steps, calculating step-by-step and overall conversion, finding where most visitors drop out, catching a stage definition that silently lost a fifth of purchases, understanding open and closed funnels, and comparing new and returning visitors.
GloryTecks Team
Training & Placement Faculty
Last updated: 25 September 2026
A funnel is a sequence of steps users take towards a goal: landing on a site, viewing a product, adding it to the cart, paying. Funnel analysis measures how many people reach each step and where they drop out, which tells a team where improvement would pay most. Analytics tools such as Google Analytics describe funnel exploration in exactly those terms: visualising the steps users take to complete a task and how well they succeed at each (Google Analytics: funnel exploration).
This guide builds a funnel from real data: 12,330 sessions on an online shop, each from a different user over a year, with the pages viewed and whether the session ended in a purchase (UCI: Online Shoppers Purchasing Intention). The dataset records a Page Value for each session, the average value of the pages visited before an e-commerce transaction, which serves as a signal that the visitor reached pages that typically precede buying.
Step 1: Define the steps, and check that they nest
Four steps: any session, viewed at least one product page, reached a page that typically precedes purchases (Page Value above zero), and purchased. Before building the funnel, check that every purchase actually passed through the earlier steps:
import io
import urllib.request
import zipfile
import pandas as pd
url = "https://archive.ics.uci.edu/static/public/468/online+shoppers+purchasing+intention+dataset.zip"
sessions = pd.read_csv(zipfile.ZipFile(io.BytesIO(urllib.request.urlopen(url).read())).open("online_shoppers_intention.csv"))
stages = {
"1 session": pd.Series(True, index=sessions.index),
"2 viewed a product page": sessions["ProductRelated"] > 0,
"3 reached a page that precedes purchases": sessions["PageValues"] > 0,
"4 purchased": sessions["Revenue"],
}
reached = pd.DataFrame(stages)
print("purchases without stage 3:", int((reached["4 purchased"] & ~reached["3 reached a page that precedes purchases"]).sum()),
"of", int(reached["4 purchased"].sum()))purchases without stage 3: 370 of 1908This check matters. 370 of the 1,908 purchasing sessions show no Page Value, so a funnel that requires stage 3 before stage 4 will count only 1,538 purchases and understate conversion by a fifth. The cause is the data, not the users: these sessions are summaries, not ordered event logs, and the Page Value proxy does not capture every path to purchase. With event data, you would check the same thing by confirming that each user's events occur in the funnel's order. Either way, report how many conversions the funnel definition excludes.
Step 2: Step and overall conversion
Counting sessions that reached each step and all the steps before it gives a strict funnel:
funnel = pd.DataFrame({"sessions": reached.cumprod(axis=1).sum()})
funnel["from previous step"] = funnel["sessions"] / funnel["sessions"].shift()
funnel["from start"] = funnel["sessions"] / funnel["sessions"].iloc[0]
print(funnel.round(3).to_string()) sessions from previous step from start
1 session 12330 NaN 1.000
2 viewed a product page 12292 0.997 0.997
3 reached a page that precedes purchases 2730 0.222 0.221
4 purchased 1538 0.563 0.125Two rates tell different stories. The step conversion, from the previous step, shows where the biggest drop is: almost everyone views a product, but only 22% of product viewers reach a pre-purchase page. Once there, 56% buy. The overall conversion, from the start, shows the funnel's total output: 12.5% of sessions under this strict definition, or 15.5% counting all 1,908 purchases. The largest drop, from browsing products to getting close to buying, is where improvements to product pages, prices or calls to action would have the most room to act.
Step 3: Compare segments
The same funnel by visitor type:
def step_rates(group):
r = reached.loc[group.index].cumprod(axis=1).sum()
return pd.Series({"sessions": r.iloc[0], "to stage 3": r.iloc[2] / r.iloc[1], "stage 3 to purchase": r.iloc[3] / r.iloc[2],
"overall": r.iloc[3] / r.iloc[0]})
print(sessions.groupby("VisitorType").apply(step_rates, include_groups=False).round(3).to_string()) sessions to stage 3 stage 3 to purchase overall
VisitorType
New_Visitor 1694.0 0.226 0.864 0.194
Other 85.0 0.188 0.875 0.165
Returning_Visitor 10551.0 0.222 0.512 0.113New and returning visitors reach the pre-purchase pages at almost the same rate, 22.6% and 22.2%. After that they diverge: 86% of new visitors who get there buy, against 51% of returning visitors. The data cannot say why, but it points to the right question. Returning visitors may be checking prices, reviewing past orders or comparing options, and understanding their behaviour at that step is where a product or marketing team should look next. The "Other" group has only 85 sessions, too few to draw conclusions.
Open and closed funnels
Tools distinguish two ways of counting. In a closed funnel, users must enter at the first step; in an open funnel, they can enter at any step (Google Analytics: funnel exploration). A closed funnel answers "of people who started the journey, how many finished?". An open funnel also counts people who arrive directly at a later step, such as a returning customer who goes straight to the cart. Choose the one that matches the question, and state it: the two can give very different conversion rates.
Choices that change the numbers
- Unit of analysis: sessions, as here, or users across several sessions. A user who browses on Monday and buys on Friday converts as a user but not as a session.
- Conversion window: how long a user has to complete the funnel. Product analytics tools such as Mixpanel build funnels from ordered sequences of events within such windows (Mixpanel: funnels).
- Step order: strict order, or any order.
- Step definitions: the exact event or page that counts, written down so the funnel is reproducible.
From numbers to action
- Find the biggest drop in step conversion, weighted by how many users it affects.
- Segment it by device, channel, visitor type or product category to see where it is worst.
- Form hypotheses about causes and look at supporting evidence, such as page speed or error rates.
- Test changes with a controlled experiment; A/B testing for data scientists covers how.
- Monitor the funnel after changes, and watch the steps after the one you improved: gains early in a funnel sometimes bring in less committed users who drop out later.
Funnels answer where people drop out; cohort analysis answers whether they come back, and customer segmentation answers who they are. Product analytics 101 connects the three.
What is a good conversion rate?
Should I analyse funnels by session or by user?
Why does my funnel show more conversions at a later step than an earlier one?
How many steps should a funnel have?
Customer behaviour analysis and marketing campaign analytics projects are part of the Data Analytics course.
Sources
- Online Shoppers Purchasing Intention Dataset (UCI Machine Learning Repository) — UCI Machine Learning Repository
- Funnel exploration (Google Analytics Help) — Google Analytics Help
- Funnels (Mixpanel documentation) — Mixpanel
GloryTecks Team
Training & Placement Faculty
The GloryTecks faculty team mentors learners across Data Science, AI and Data Engineering, with a focus on real-time projects and placement readiness in Hyderabad.
Want to master Data Analytics?
Join GloryTecks’ expert-led Data Analytics training in Hyderabad with real-time projects and 100% placement support.
Related articles
Spreadsheet to Insight: A Repeatable Analysis Workflow
A repeatable workflow for turning a raw spreadsheet into an insight, followed end to end on a real 541,909-row sales workbook: writing the question down, fingerprinting the raw file, logging what every cleaning rule removes, answering the question, reconciling before sharing, and making the whole analysis rerunnable.
Data Analyst Roadmap 2026: Skills, Tools and Timeline
A data analyst roadmap for 2026: the six stages to learn in order, from spreadsheets and SQL to BI tools, statistics and communication, what each stage should let you do, a realistic part-time timeline, a project that proves each stage, and how to tell when you are ready to apply for analyst roles.
Excel vs Power BI: Which Should You Learn First?
Should you learn Excel or Power BI first? For most beginners, a slice of Excel first, then Power Query and the data model, which Excel and Power BI share, and then Power BI. Here is why, what each tool teaches on its own, and which to start with in your situation.