Grab Google Analytics Data x
⚠️ THIS IS A WORK IN PROGRESS
googleAnalyticsR is an amazing package by Mark Edmondson
1
## setup
2
library(googleAnalyticsR)
3
4
## authenticate
5
ga_auth()
6
7
## get your accounts
8
account_list <- ga_account_list()
9
10
## account_list will have a column called "viewId"
11
account_list$viewId
12
13
## View account_list and pick the viewId you want to extract data from
14
ga_id <- 123794729
15
16
## simple query to test connection
17
## simple query to test connection
18
extract <- google_analytics(ga_id,
19
date_range = c("2021-01-01", "2021-02-01"),
20
metrics = "sessions",
21
dimensions = c("date","medium","landingPagePath"),
22
anti_sample = TRUE)
23
View(extract)
Copied!
Copy link