Use R for Data Analysis
Learn to work with the googleAnalyticsR package in R for data analysis.
We'll cover the following
- The googleAnalyticsR package
- Dimensions and metrics
- Install googleAnalyticsR
- R packages for data analysis
- Authenticate our Google Analytics account
- List Google Analytics accounts and properties
- Obtain our website’s viewId
- Daily count of website users
- Users by device type
- Number of page views per page
- Users by geographic location
- Avoiding data sampling
- Let’s visualize our data!
The googleAnalyticsR
package
The googleAnalyticsR
R package makes it easy and fun to query our Google Analytics data using the GA API. There are numerous functions available in this package that enable us to control the data we want to retrieve. Before diving into the code, let’s spend some time learning about Google Analytics dimensions and metrics.
Dimensions and metrics
In order to analyze our Google Analytics data, we need to gain a basic understanding of dimensions and metrics.
Dimensions are attributes of our data and metrics are quantitative measurements. For example, to analyze the count of users on our website in the last 60 days, the dimension is date
and the metric is users
.
Google Analytics supports hundreds of dimension-metric combinations that we can explore later. In this lesson, we will focus on some of the most used combinations.
Install googleAnalyticsR
To install the googleAnalyticsR
package, we can use the following command in the R console:
Get hands-on with 1400+ tech skills courses.