Conversion Rate Optimization: Using R to predict conversion rates

Feb. 10, 2021, 4:55 p.m.
R · 7 min read
Conversion Rate Optimization: Using R to predict conversion rates

What is a conversion rate? 

A conversion rate is the number of people who clicked on your website and bought the service provided. The key here is the user MUST buy the product--whether the product is subscribing for a monthly newsletter, submitting an interest form, or calling a service offered on a website. 

Conversion rates provide accurate, statistical evidence determining if certain marketing strategies and techniques are effective in convincing users to buy offered products and services. 


Average conversion rate

According to, the average landing page conversion rate across all industries is 2.35% while nicer pages have a conversion rate of 5.31%, and the most successful pages have a conversion rate of around 11.45%. 


What is a good conversion rate and what does it mean?

Based on the information above, a good conversion rate is between 2% and 5%, with 10% being exceptional! If you have a conversion rate between these percentages it means your web design and marketing strategies are working, so keep it up because you're heading in the right direction! 


What is a low conversion rate and what does it mean?

A low conversion rate would obviously be below 2%, so if you are in this situation reconsidering your web design and marketing techniques is the best option to improve your conversion rate. When thinking of new strategies, picture yourself as one of your users and think of features you and other users might want on the website. Sometimes knowing exactly what people want is difficult, but taking on a users' perspective when visiting your website can assist in decision making.  


How to predict conversion rates

In this article, I perform a conversion rate test in RStudio based on an imaginary website where I want people to sign up for my monthly newsletter about interesting sports facts. For the purpose of this demonstration, I will use two versions of my website, one with an old design and the other with a new design. Here is an example of how my websites might look to see if there is a difference in conversion rates between the old page and the new page: 

I changed the font size of "Want Interesting Sports Facts" to a larger size for my new website.

I begin my experiment by developing a null hypothesis or the default hypothesis always stating there is no difference between two statistical variables being measured. My null hypothesis is there is no difference between the old and new versions of my website and the higher conversion rate on one website rather than the other is simply due to chance. 

Next, I draft an alternative hypothesis or a hypothesis stating there is a difference between the statistical variables and a new theory needs consideration. In my case, the alternative hypothesis is there is a difference between the website's versions which causes a higher conversion rate on one website rather than the other. This means the changes I made to the new website are the direct cause of a higher conversion rate.  


Predicting conversion rates - Step 1: Gathering data 

On the first day of having my new and old websites active I gathered the amount of people who converted and those who did not. 

converted <- c(9, 20)
notconverted <- c(27, 38)
rowNames <- c("old website", "new website")
results <- data.frame(converted, notconverted)
row.names(results) <- rowNames

I begin creating a list called converted with two values and make another list called notconverted. Next, I assign a table with two row names, one called old website and the other new website. I create a data frame called results consisting of the data in converted and notconverted. Then, I use to transform results into a table as seen below.   


Predicting conversion rates - Step 2: Calculating conversion rate 


pageperformance <- results %>%
  mutate(visits = converted + notconverted) %>%
  mutate(conRate = round((converted / visits) * 100, 2))

Next, I calculate the conversion rates first by loading in dplyr into my library, then I make a new function named pageperformance where I call on results to add the data in converted and notconverted by using mutate and naming the equation visits. Once again, I used mutate to create conRate by dividing converted by visits, multiplying it by 100 and repeating it twice. Finally, I print pageperformance as seen below.  

My conversion rate for my old website is 25% while my new website has a conversion rate of 34.48%, so clearly the new website makes a difference; although, I cannot draw a conclusion yet. Running another test helps determine whether the difference in conversion rates is due to chance or due to the difference in font sizes. 


Predicting conversion rates - Step 3: Testing my hypothesis 

Now, I test my null hypothesis which helps determine exactly why my conversion rate increased. 

chisq.test(results, correct = FALSE)

I ran a chi-squared test to further analyze my data. A chi-squared test determines whether variables are independent or related to one another. I set correct=FALSE so Yate's Continuity Correction is not calculated which corrects data for small sample sizes. After running the function, my p-value is .3332, indicating no difference exists between each website. A p-value above .05 means the null hypothesis cannot be rejected. 

However, I performed this test based on the first day of having both websites active, so performing the test in a few days once I have more users visiting my website is ideal. 


Predicting conversion rates - Step 4: Gathering data after a few days

After a few days, more users visited my websites providing a more accurate p-value as to whether or not there is a difference between the two websites which leads to a higher conversion rate on one rather than the other.

converted2 <- c(54, 156)
notconverted2 <- c(77, 134)
rowNames2 <- c("old website", "new website")
results2 <- data.frame(converted2, notconverted2)
row.names(results2) <- rowNames2

All of my data is named similarly to how I did so previously, except I changed the names (added a 2 after every name) to reflect data with different or new values. Here is the new data: 


Predicting conversion rates - Step 5: Calculating a new conversion rate

pageperformance2 <- results2 %>%
  mutate(visits2 = converted2 + notconverted2) %>%
  mutate(conRate = round((converted2 / visits2) * 100, 2))

I ran the exact same function as before but used the updated data from both websites. You can see in the printed table below that a difference hardly exists between my old and new conservation rates, so does the new website serve any purpose?

Once again performing a chi-squared test indicates whether or not the higher conversion rate on the new website is due to chance or if it is caused by the changes I made.  


Predicting conversion rates - Step 6: Testing my hypothesis again


Once again I ran chisq.test using the data in results2 but excluded correct=FALSE because I have enough data to receive a more accurate p-value. My p-value is .02242, meaning there is enough statistical evidence supporting my alternative hypothesis there is a difference between the two websites, causing a higher conversion rate on one website compared to the other.



I can conclude changing the word sizing in the new website increased the user's odds of subscribing to my newsletter about interesting sports facts. 

Remember, the larger the sample size (or data) the more accurate the p-value will be so you know whether the change in conversion rates is to due chance or caused by other factors. So if you want to perform this test on your own remember the more user visits the better! 


How to increase conversion rates? 

Perhaps your p-value after gathering more users is still above .05, what does that mean exactly? It means there is not enough statistical evidence to conclude the new website has a higher conversion rate than the old website. In other words, you fail to reject the null hypothesis and the higher conversion rate is due to chance. 

A few ways to increase conversion rates include: 

  • remove distractions or irrelevant information  
  • add customers' reviews and testimonials 
  • change the website's color scheme or font sizes
  • shorten surveys or forms 
  • have a call to action


Conversion rate optimization services

Realize you can optimize your conversion rates on your own! Conversion rates are strongly tied to marketing, so improving your knowledge in marketing can be the best strategy in improving conversion rates at a low cost.  

Additionally, if you understand the psychology and social behaviors of humans, the process of determining what appeals best to users becomes easier. For example, shades of bright red encourage people to take action so having brightly colored red buttons might increase consumers' likeliness to purchase products.

Post a Comment
Join the community

Written By