Interactive Google Analytics Charting in R with Plot.ly

We will walk around creating an interactive line chart in R with Google Analytics data and publishing online at Plot.ly.  If you haven’t setup Rstudio please read my previous post here.  For the charting part, we will be using Plot.ly, so let’s start by installing the required libraries: 

Install Plotly package.

Then copy paste the code below:

Execute Script

Be sure to replace with your Google Analytics profileId.  And we will get visualization like below.

line-plotly

Configure Plot.ly API

Now, let’s publish the chart to Plot.ly by configuring API settings for this. Use the code below to setup:

You can generate API key here at settings.  

Publishing Chart

To publish use:

post-to-plotly

Below is the live embedded chart and link.