Recently I have been playing a lot with Tableau, and I decided to extract data from my Google Analytics Account in regard to one of my blogs and visualize the extracted data. Today I want to share my findings. Every visualization gives us some insights into the data. Data connection with Google Analytics opens pretty quick. You can select up 7 dimensions and 10 measures to work with.
The blog is about traveling, and it’s in Russian. Its main audience is in Russia, Eastern Europe, and United States. Below you can see number of sessions, pageviews, and new users by country and year quarter as well as a map.
The bubble and waterfall charts below is basically showing the same information, but I like how they look 🙂 The waterfall chart shows the number of organic searches by country. We can see that although the U.S. is the third country by number of pageviews, it’s the second country by the number of organic searches. And Belarus where I am from is the second by number of pageviews, but the forth by the number of organic searches. I guess my friends and family from Belarus influenced this result.
You will need RGoogleAnalytics package to extract Google Analytics data in R. The package was developed by Michael Pearmain, and it provides functions for accessing and retrieving data from the Google Analytics API. This article is based on the package’s supporting documentation. To download the documentation use this link: RGoogleAnalytics documentation.
First, install the package RgoogleAnalytics. It requires the packages “lubridate” and “httr” to be installed as well.
If you have problems with downloading the packages, check your R version. RGoogleAnalytics requires R version 3.0.2 or newer.
Then, you will use the Auth function to authorize the RGoogleAnalytics package to your Google Analytics Account using Oauth2.0.
The function Auth expects a Client ID and Client Secret. To get these, you will have to register an application with the Google Analytics API:
1. Go to the Google Developers Console
2. Create a New Project and enable the Google Analytics API
3. On the Credentials screen, create a new Client ID for Application Type “Installed Application”
4. Copy the Client ID and Client Secret to your R Script
Enable Google Analytics API
Create a new Client ID
Now you can authorize the RGoogleAnalytics package to your Google Analytics Account.