Page Visits Funnel Code

---
title: "Page Visits Funnel"
output: html_notebook
---

```{r message = FALSE, error=TRUE}
# load packages
library(readr)
library(dplyr)
# load data
visits <- read_csv("visits.csv")
cart <- read_csv("cart.csv")
checkout <- read_csv("checkout.csv")
purchase <- read_csv("purchase.csv")
# inspect data frames
head(visits)
head(cart)
head(checkout)
head(purchase)
# define visits_cart here:
visits_cart <- visits %>%
  left_join(cart)
visits_cart


# define total_visits here:
total_visits = nrow(visits)
total_visits

# define visit_no_cart here:
visit_no_cart <- visits_cart %>%
  filter(is.na(cart_time))
visit_no_cart

visit_no_cart_count <- nrow(visit_no_cart)
visit_no_cart_count
# calculate visit_no_cart_percent here:
visit_no_cart_percent <- visit_no_cart_count/total_visits
visit_no_cart_percent

# define cart_checkout here:
cart_checkout <- cart %>% 
  left_join(checkout)
cart_checkout


# define total_carts here:
total_carts = nrow(cart)
total_carts

# define cart_no_checkout here:
cart_no_checkout <- cart_checkout %>% 
   filter(is.na(checkout_time))
cart_no_checkout

cart_no_checkout_count <- nrow(cart_no_checkout)
cart_no_checkout_count
# calculate cart_no_checkout_percent here:
cart_no_checkout_percent <- cart_no_checkout_count/total_carts
cart_no_checkout_percent
# define all_data here:
all_data <- all_data %>%
  mutate(time_to_purchase = purchase_time - visit_time)
head(all_data)


# define total_checkout here:


# define checkout_no_purchase here:




# calculate checkout_no_purchase_percent here:


# update all_data with time_to_purchase column here:


# inspect the updated all_data data frame here:

# define time_to_purchase here: