Description Key features Useage Bug reports Author(s) Examples
A package for extracting data from Google Analytics API into R.
Support for OAuth 2.0 authorization;
Access to the following Google Analytics APIs:
Management API: access to configuration data for accounts, web properties, views (profiles), goals and segments;
Core Reporting API: query for dimensions and metrics to produce customized reports;
Multi-Channel Funnels Reporting API: query the traffic source paths that lead to a user's goal conversion;
Real Time Reporting API: report on activity occurring on your property at the moment;
Metadata API: access the list of API dimensions and metrics and their attributes;
Access to all the accounts which the user has access to;
API responses is converted directly into R as a data.frame
;
Auto-pagination to return more than 10,000 rows of the results by combining multiple data requests.
To report a bug please type: utils::bug.report(package = "RGA")
.
Once you have the package loaded, there are 3 steps you need to use to get data from Google Analytics:
Authorize this package to access your Google Analytics data with the authorize
function;
Determine the profile ID which you want to get access to with the list_profiles
function;
Get the results from the API with one of these functions: get_ga
, get_mcf
or get_realtime
.
For details about this steps please type into R: browseVignettes(package = "RGA")
Before posting a bug please try execute your code with the with_verbose
wrapper. It will be useful if you attach verbose output to the bug report. For example: httr::with_verbose(list_profiles())
Post the traceback()
output also may be helpful.
To report a bug please type into R: utils::bug.report(package = "RGA")
Artem Klevtsov a.a.klevtsov@gmail.com
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | ## Not run:
# load package
library(RGA)
# get access token
authorize()
# get a GA profiles
ga_profiles <- list_profiles()
# choose the profile ID by site URL
id <- ga_profiles[grep("http://example.com", ga_profiles$website.url), "id"]
# get date when GA tracking began
first.date <- firstdate(id)
# get GA report data
ga_data <- get_ga(id, start.date = first.date, end.date = "today",
metrics = "ga:users,ga:sessions",
dimensions = "ga:userGender,ga:userAgeBracket")
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.