Learn R Programming

RGA (version 0.4.2)

get_realtime: Real Time Reporting API

Description

Get the Anaytics data from Real Time Reporting API for a view (profile).

Usage

get_realtime(profileId = getOption("rga.profileId"), metrics = "rt:activeUsers", dimensions = NULL, sort = NULL, filters = NULL, max.results = NULL, token)

Arguments

profileId
character. Unique table ID for retrieving Analytics data. Table ID is of the form ga:XXXX, where XXXX is the Analytics view (profile) ID. Can be obtained using the list_profiles or via the web interface Google Analytics.
metrics
character. A comma-separated list of real time metrics. E.g., "rt:activeUsers". At least one metric must be specified.
dimensions
character. A comma-separated list of real time dimensions. E.g., "rt:medium,rt:city".
sort
character. A comma-separated list of dimensions or metrics that determine the sort order for real time data.
filters
character. A comma-separated list of dimension or metric filters to be applied to real time data.
max.results
integer. The maximum number of entries to include in this feed.
token
Token2.0 class object with a valid authorization data.

Value

A data frame including the real time data for a view (profile). Addition information about profile and request query stored in the attributes.

References

Real Time Reporting API - Dimensions & Metrics Reference

See Also

authorize

Other Reporting API: firstdate, get_ga, get_mcf

Examples

Run this code
## Not run: 
# # get token data
# authorize()
# # get report data
# ga_data <- get_realtime(XXXXXXX, metrics = "rt:activeUsers",
#                         dimensions = "rt:source,rt:medium")
# # get active users in realtime (press Esc to abort)
# while (TRUE) {
#     cat("\014")
#     print(get_realtime(XXXXXXX, metrics = "rt:activeUsers"))
#     Sys.sleep(2)
# }
# ## End(Not run)

Run the code above in your browser using DataLab