If you’re running an e-commerce store, you’ve probably been there: people are visiting your site, browsing around, and then… poof, they’re gone without buying anything. Frustrating, right? That’s where funnel analysis comes in. It’s all about figuring out what’s going on at each step of the customer journey and spotting where they’re dropping off.
In this article, I’ll show you how I use BigQuery to break down and analyze the e-commerce funnel step by step. Let’s dive in.
Okay, so here’s the deal: a funnel is just a fancy name for the journey your customers take on your site, from the moment they land to when (hopefully) they make a purchase.
It looks something like this:
The goal of funnel analysis is simple: figure out how many people make it from one step to the next, and where you’re losing them.
If you’re storing event data in BigQuery, you can run queries to track how users move through each step of the funnel. Let me show you how.
Here’s a simple query that shows how many users move from one step to the next:
WITH funnel_data AS (
SELECT
user_pseudo_id,
event_name,
MIN(event_timestamp) AS first_event_time
FROM your_dataset
WHERE event_name IN ('page_view', 'add_to_cart', 'begin_checkout', 'purchase')
GROUP BY
user_pseudo_id, event_name
),
step_transitions AS (
SELECT
user_pseudo_id,
MAX(CASE WHEN event_name = 'page_view' THEN first_event_time END) AS homepage_view_time,
MAX(CASE WHEN event_name = 'add_to_cart' THEN first_event_time END) AS add_to_cart_time,
MAX(CASE WHEN event_name = 'begin_checkout' THEN first_event_time END) AS checkout_time,
MAX(CASE WHEN event_name = 'purchase' THEN first_event_time END) AS purchase_time
FROM funnel_data
GROUP BY all
)
SELECT
COUNT(DISTINCT user_pseudo_id) AS total_users,
COUNTIF(homepage_view_time IS NOT NULL) AS step_1_homepage,
COUNTIF(add_to_cart_time IS NOT NULL AND homepage_view_time IS NOT NULL) AS step_2_to_cart,
COUNTIF(checkout_time IS NOT NULL AND add_to_cart_time IS NOT NULL) AS step_3_to_checkout,
COUNTIF(purchase_time IS NOT NULL AND checkout_time IS NOT NULL) AS step_4_to_purchase
FROM step_transitions;
page_view
, add_to_cart
, etc.The output will look something like this:
Step |
Users |
---|---|
Homepage Visits |
10,000 |
Product Page → Cart |
4,500 |
Cart → Checkout |
2,000 |
Checkout → Purchase |
1,200 |
From the table above, you can see:
This tells you exactly where to focus your efforts. For example:
Once you know where the drop-offs are, it’s time to take action. Here are a few things I’ve tried (and they work):
If people aren’t adding items to their cart:
If users drop off during checkout:
You can also adjust the query to compare transitions over time—for example, before and after a design update:
SELECT
FORMAT_TIMESTAMP('%Y-%m-%d', TIMESTAMP_MICROS(MIN(event_timestamp))) AS date,
COUNT(DISTINCT user_pseudo_id) AS total_users,
COUNTIF(add_to_cart_time IS NOT NULL) AS step_2_to_cart,
COUNTIF(checkout_time IS NOT NULL) AS step_3_to_checkout,
COUNTIF(purchase_time IS NOT NULL) AS step_4_to_purchase
FROM step_transitions
GROUP BY all
ORDER BY 1;
This way, you can see if your changes are actually making a difference.
Funnel analysis doesn’t need to be overwhelming. With a few simple BigQuery queries, you can break down your user journey, pinpoint drop-offs, and start making improvements. Remember, even small tweaks—like better product images or a smoother checkout process—can make a huge difference in your conversion rates.
So, roll up your sleeves, give it a shot, and let’s turn those visitors into customers!
Thank you for your time; sharing is caring! 🌍