Doing A/B-testing with Google Analytics and R, Part 2

Recently I described a way to do [A/B-testing with Google Analytics and R](/2015/08/20/doing-a-b-testing-with-google-analytics-and-r/. I wrote about tests with a two-way outcome: bounced or not bounced. But what do we do when the metric has more than two possible outcomes? Let’s say something like sessionDuration or pageLoadTime. Then Google just gives you an aggregated value like avgSessionDuration or avgPageLoadTime. You don’t get any information about the distribution of this metric. So you have to do it on your own!

Doing A/B-testing with Google Analytics and R

There are several ways for A/B-Testing with Google Analytics. First you can use the Google way. Google calls it [Content Experiments](https://support.google.com/analytics/answer/1745147?hl=en. But you have to define a goal when you set up an experiment. If you want to investigate several metrics I thinks the better way is to do the analysis on your own. Use Google Analytics to create the data. But do the analysis on your own. But first I’d like to summarize what I’d like to do:

Caching and other enhancements to RGoogleAnalytics

RGoogleAnalytics is a great R-package for accessing Google Analytics-data from R via the API. The package was written by Tatvic, a webanalytics consulting company from India. They also offer regularly free webinars about webanaytics. The excellent R-blog R-bloggers.com also published several posts about RGoogleAnalytics: How to extract Google Analytics data in R using RGoogleAnalytics Query Multiple Google Analytics View IDs with R I use this R-package regularly. But I came across some shortcomings: First I missed caching of the data I retrieved from Google.

Using otf-fonts in Knitr’s LaTeX-Documents

As I mentioned earlier I’ve wanted to use otf-fonts in ggplot2-graphics Rmd-Files The next step is to use them in Knitr‘s RMarkdown-documents. That’s simple: Just use it as I showed earlier. 1 2 3 4 5 6 7 8 9 10 11 title: "demo" output: html_document ```{r} library(ggplot2) ggplot(mtcars, aes(x=wt, y=mpg, color=factor(gear))) + geom_point() + ggtitle("Fuel Efficiency of 32 Cars") + xlab("Weight (x1000 lb)") + ylab("Miles per Gallon") + theme(text=element_text(size=16, family="Source Code Pro")) ``` Rnw-Files But using these fonts in Rnw-files — that’s embedded R-code in LaTeX-files — seems to be a little more complex.

Using TeXnicle as editor for knitr-documents

TeXnicle is my favourite editor for writing LaTeX documents. It is available for Max OS X. So I’d like to use it when writing knitr‘s Rnw-files. Rnw-files are LaTeX-files with embedded R-code in it. So Rnw-files need to be preprocessed. The result is a tex-file which will be compiled by pdflatex or xelatex. Processing is done by so called engines. TeXnicle comes with a bunch of different engines. You can see them in preferences (hit ⌘-,) on tab “Typesetting”.