Visualizing your websites’ ecommerce performance with R

[This article was first published on Tatvic Blog » R, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

In this blogpost, I want to dive deeper into the explanation of the relationship between Frequency and Recency of Visits with the Conversion Rate and Average Order Value. I have used the RGA package for data extraction and Dr. Hadley Wickham’s ggplot2 package to achieve the visualizations.

Here’s the data aggregation script :

#transactions dataframe contains the input data extracted via RgoogleAnalytics
head(transactions, n = 3)
#  visitsToTransaction daysToTransaction transactions transactionRevenue
#1                   1                 0         1639           11505429
#2                  10                 1            1               3700
#3                  10                10            1               6050
transactions$visitsToTransaction <- as.numeric(transactions$visitsToTransaction)    #Convert metrics from chr to numeric
transactions$daysToTransaction <- as.numeric(transactions$daysToTransaction)
#trans_data is a placeholder data frame
str(transactions)
str <- c("1-3","4-6","7-9")                   #Create three labels
trans_data <- data.frame(Visits_To_Transaction=c(1:9),
                  Days_To_Transaction=c(1:9),
                  Transactions = c(1:9),
                  Revenue = c(1:9),
                  Average_Order_Value = c(1:9),
                  stringsAsFactors=F)         #Placeholder to hold aggregated data frame
index<-1                  #Initialize index
for (i in 1:3)
{
  for(j in 1:3)
  {
    trans_data$Visits_To_Transactions[index] <- str[i]
    trans_data$Days_To_Transactions[index] <- str[j]
    subset <- transactions[(transactions$visitsToTransaction>=(3*i-2)&transactions$visitsToTransaction=(3*j-2)&transactions$daysToTransaction

We now convert our data into a visualization using the ggplot2 package. Here’s the command:

require(ggplot2)
aov <- ggplot(trans_data,aes(Visits_To_Transactions,Days_To_Transactions)) +
  geom_tile(aes(fill=Average_Order_Value),colour="black") +
  theme_bw() +
  geom_text(aes(label=round(trans_data$Average_Order_Value),
                size=trans_data$Average_Order_Value),color="white") +
  scale_size(range=c(3,12)) +
  ggtitle("Average Order Value (in Rs.)") +
  xlab("Visits to Transaction") +
  ylab("Days to Transaction") +
  theme(legend.position="none",
        axis.text.x= element_text(size=16),
        axis.text.y=element_text(size=16),
        axis.title.x=element_text(face="bold"),
        axis.title.y=element_text(face="bold"),
        plot.title = element_text(face="bold",size=30))
aov

 

Average Order Value

Let us make some quick inferences:

  • When the consumers visit 1-3 times across a period of 4-6 days they tend to buy the most expensive products
  • When they visit the site 7-9 times across a very small period of 1-3 days, these might be the consumers who visit repeatedly to keep a tab on offers and prices of a product of their choice they too have a higher Average Order value
  • Spontaneous buying decisions are made when the Visits and Days to Transaction are in the 1-3 categories. As expected, the average order value for these transactions is on the lower end.

Let us do a similar exercise for the Conversion Rate. We extract data corresponding to the dimensions: Visit Count, Days since Last Visit and Metrics: Visits. Repeat the same steps as before. We already had the Transactions binned and categorized earlier. We now divide the total number of Transactions across each category to the Total Visits in order to get the Conversion Rate and plot it.

Conversion Rate

Both the plots stacked up together help us understand the relationship between the Average Order Value and the Conversion Rate which in this case seems to be an inverse relationship i.e. AOV tends to be higher when Conversion Rate is the lowest. Now, this correlation may not imply an underlying causation therefore we need to drill down further to verify our hypothesis.

Consumers do tend to visit the website multiple times before making a purchase. Some might buy right away, but most of them will research a bit and come back. With this realization, we could focus on giving them more information to help with their research and getting them to convert at their own pace. On the other hand, if the time period is short (for e.g. 1-3 Visits in 1-3 Days) and the purchase is more spontaneous we have some room for improvement here (Average Order Value: 6497, Conversion Rate 1.37 %). We could play with pricing strategy and thereby to increase the Average Order Value or provide a referral discount and get more consumers to convert. Of course, this has to be done keeping the site’s business objective in mind.

Would you like to understand the value of predictive analysis when applied on web analytics data to help improve your understanding relationship between different variables? We think you may like to watch our Webinar - How to perform predictive analysis on your web analytics tool data. Watch the Replay now!

Kushan Shah

Kushan Shah

Kushan is a Web Analyst at Tatvic. His interests lie in getting the maximum insights out of raw data using R and Python.

Website - Twitter - Facebook - More Posts

To leave a comment for the author, please follow the link and comment on their blog: Tatvic Blog » R.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)