Analyze web traffic data with Google Analytics and R

[This article was first published on Revolutions, 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.

If you run an e-commerce site, blog or other web property there's a good chance you use Google Analytics to monitor traffic, look at visitor sources, and measure conversions. And while Google Analytics is quite powerful at looking at historic activity on your site, it lacks much in the way of predictive analytics. That's where R shines of course, and it's now quite easy to connect R to your Google Analytics account to make use of R's superior data visualization, forecasting, and other advanced analytics capabilities.

Digital analytics expert Randy Zwitch explains how to use the rga package for R to access your Google Analytics data and import it into R. There, you can use all of R's capabilities to analyze the data. For example, you can use boxplots to look at the proportion of visits to a site via a Google search where the search terms are actually provided:

To interface with Google Analytics you'll need an access token for the Google Analytics API console (the Tatvic Blog provides some tips for obtaining one). Once you're set up, you can run the code at the link below to create your own version of the chart above, or simply start using R to analyze your web traffic data. (not provided): Using R and the Google Analytics API

To leave a comment for the author, please follow the link and comment on their blog: Revolutions. 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)