E-commerce Funnel Analysis

Author

Aayan Khan & Aditya Gupta

Introduction

  • E-commerce Funnel Analysis tracks user journey
  • Stages: Visit → Cart → Purchase
  • Helps understand user behavior

Problem Statement

  • Users drop off before completing purchase
  • Need to analyze where users leave
  • Use real dataset for analysis
  • Funnel chart to visualize drop-off

Objective

  • Understand user journey
  • Identify drop-off points
  • Improve conversion rate
  • Support business decisions

Steps Involved

  • Load libraries
  • Load dataset
  • Analyze data
  • Create funnel stages
  • Visualize results

Libraries Used

library(ggplot2)
Warning: package 'ggplot2' was built under R version 4.5.3
library(dplyr)

Attaching package: 'dplyr'
The following objects are masked from 'package:stats':

    filter, lag
The following objects are masked from 'package:base':

    intersect, setdiff, setequal, union
library(readr)
library(maps)
Warning: package 'maps' was built under R version 4.5.3

ggplot2 → Visualization dplyr → Data manipulation readr → Data loading maps → Optional visualization

Dataset

Retail transaction dataset Quantity → Number of items Unit Price → Price per item Country → Customer location

Load Dataset

df <- read_csv("data.csv")   # CHANGE THIS FILE NAME
Rows: 541909 Columns: 8
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (5): InvoiceNo, StockCode, Description, InvoiceDate, Country
dbl (3): Quantity, UnitPrice, CustomerID

ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.

Data Preprocessing

df <- df %>%
  filter(Quantity > 0, UnitPrice > 0) %>%
  mutate(Revenue = Quantity * UnitPrice)

Removed invalid values Filtered negative/zero entries Calculated revenue

Data Aggregation

summary_data <- df %>%
  group_by(Country) %>%
  summarise(TotalRevenue = sum(Revenue))

Grouped by country Calculated total revenue Reduced dataset complexity

Funnel Data Creation

funnel <- data.frame(
  stages = c("Visitors", "Product View", "Add to Cart", "Checkout", "Purchase"),
  users = c(1000, 800, 500, 300, 150)
)

Represents user journey stages Shows drop at each level

Funnel Chart

ggplot(funnel, aes(x = reorder(stages, -users), y = users, fill = stages)) +
  geom_bar(stat = "identity") +
  coord_flip() +
  geom_text(aes(label = users), hjust = -0.2) +
  theme_minimal() +
  labs(title = "E-commerce Funnel", x = "Stages", y = "Users")

Visual representation of funnel Shows user drop-off clearly

##Key Insights High drop after product view Drop before checkout (UX issue) Low purchase rate

Business Impact

Improve UI/UX Optimize checkout process Increase customer trust Boost conversions

Conclusion

Funnel shows user behavior clearly Identifies weak stages Helps improve business strategy