Interactive Google Analytics Charting in R with

We will walk around creating an interactive line chart in R with Google Analytics data and publishing online at  If you haven’t setup Rstudio please read my previous post here.  For the charting part, we will be using, 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.


Configure API

Now, let’s publish the chart to 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:


Below is the live embedded chart and link.