Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryanpraski/9af765e827196d91e3d3e715a3ae9c7d to your computer and use it in GitHub Desktop.
Save ryanpraski/9af765e827196d91e3d3e715a3ae9c7d to your computer and use it in GitHub Desktop.
How many unique visitor viewed two or more of a group of pages (in this case shoes or socks pages). Used Adobe Analytics data warehouse to export Visitor_ID, Pages, and Page Views then got a count of visitor ids that viewed two or more of pages that contained shoes or socks in the page name. This count of visitor ids is the number of unique visi…
library(dplyr)
library(tidyr)
library(ggplot2)
df <- read.csv("C:/Users/praskry/Desktop/more_than_1.csv", header = TRUE)
df %>% summarize(UVs = n_distinct(Visitor_ID)) #unique visitor count
df1 <-filter(df, grepl('shoes|socks',Pages)) #filter to only include prod pages
df2 <-df1 %>% group_by(Visitor_ID) %>% filter(n()>1)
df3<-df2 %>% group_by(Visitor_ID) %>% summarize(count=n())
df3 %>% group_by(count) %>% summarize(total.count=n())
ggplot(data=df3, aes(x=count)) + geom_bar(stat="count")
#df4 <-spread(df2,Pages,Page.Views,fill = 0) #make long data wide- pages as column vis_id row
## write to csv row.names=FALSE does not write row numbers to csv
write.csv(df3, 'C:/Users/praskry/Desktop/df3.csv', row.names = FALSE)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment