THIS BRANCH IS MEANT TO ALLOW THE USE OF A PROXY THAT INJECTS AUTHENTICATION DETAILS TO THE REQUESTS INSTEAD OF HAVING TO DO THAT FROM R.
MODIFIED SAMPLE USE:
library(devtools) # Load development tools
dev_mode(on=T) # Load package TEMPORARILY
install_github("g2010a/RSiteCatalyst", ref="master")# Load custom fork
# install_local("~/gitrepos/RSiteCatalyst", ref="master")
library(RSiteCatalyst) # ...
# Start connection (dummy key, user and company are needed to bypass default checks and retrieve an endpoint)
SCAuth("<<your_username>>:<<your_login_company>>", "DUMMYDUMMYDUMMYDUMMYDUMMYDUMMY12", url_base="<<URL to the proxy server>>")
# Authenticating using username and shared secret from account settings
GetReportSuites()
R client library for the Adobe Analytics 1.4 API
RSiteCatalyst v1.4 is on CRAN. You can also install directly from GitHub.
install.packages("devtools")
library(devtools)
install_github("randyzwitch/RSiteCatalyst", ref="master")
library(RSiteCatalyst)
You may also need to install other packages that RSiteCatalyst v1.4 depends on.
install.packages(c("jsonlite","plyr","httr","stringr","digest","base64enc"))
Authorisation can be done using the legacy auth method (username:company + shared secret), or using the newer OAUTH method. Either is fine, but ultimately you should move towards using the OAUTH method, as the legacy auth method is deprecated.
The OAUTH method is not universally available for all Adobe Analytics accounts, so legacy auth remains the default.
This auth method is pretty straight-forward. You will simply need your username, and your shared secret, which you can retrieve from your account settings page in the Adobe Analytics web interface.
SCAuth("your_username:your_company", "your_shared_secret")
First you will need to create an application in the Adobe Dev Center. The application name can be whatever you want. The redirect URI should be left blank.
This will provide you with a identifier and secret that you can use to access the Adobe Analytics API.
SCAuth("your_identifier",
"your_secret",
"your company")
Once you've authorised, reports can be queued and retrieved using the helper functions for each report type.
RSiteCatalyst v1.4 has helper functions that make it easier to generate all report types (ranked, overtime, trended, pathing, fallout). These take parameters in R, convert them to JSON, then call JsonQueueReport.
Returns an overtime report. This is similar to the key metrics report in that the only granularity allowed is time.
QueueOvertime requires a start and end date, a reportsuite ID, and a character vector of metrics.
date.from <- "2014-01-01"
date.to <- "2013-01-07"
reportsuite.id <- "your_report_suite"
metrics <- c("visits","uniquevisitors","pageviews")
report.data <- QueueOvertime(reportsuite.id, date.from, date.to, metrics)
You may also wish to set any of the 5 optional named parameters.
date.from <- "2014-01-01"
date.to <- "2014-01-07"
reportsuite.id <- "your_report_suite"
metrics <- c("visits","uniquevisitors","pageviews")
date.granularity <- "hour"
segment.id <- "Visit_Natural_Search"
anomaly.detection <- TRUE
data.current <- TRUE
expedite <- TRUE
report.data <- QueueOvertime(reportsuite.id, date.from, date.to, metrics,date.granularity=date.granularity,segment.id=segment.id,anomaly.detection=anomaly.detection,data.current=data.current,expedite=expedite)
Returns a ranked report. This is an ordered list of elements and associated metrics with no time granularity.
QueueRanked requires a start and end date, a reportsuite ID, a character vector of elements and a character vector of metrics.
date.from <- "2014-01-01"
date.to <- "2014-01-07"
reportsuite.id <- "your_report_suite"
metrics <- c("visits","uniquevisitors","pageviews","event10")
elements <- c("page","geoCountry","geoCity")
report.data <- QueueRanked(reportsuite.id, date.from, date.to, metrics, elements)
You may also wish to set any of the 6 optional named parameters. The 1.4 API only supports this for the first element specified. In the example below, selected applies to the first element, page.
date.from <- "2014-01-01"
date.to <- "2013-01-07"
reportsuite.id <- "your_report_suite"
metrics <- c("visits","uniquevisitors","pageviews","event10","event10")
elements <- c("page","geoCountry","geoCity")
top <- 100
start <- 100
selected <- c("Home","Search","About")
segment.id <- "dw:12345"
data.current <- TRUE
expedite <- TRUE
report.data <- QueueRanked(reportsuite.id, date.from, date.to, metrics,elements,top=top,start=start,selected=selected,segment.id=segment.id,data.current=data.current,expedit=expedite)
Returns a trended report. This is an ordered list of elements and associated metrics with time granularity.
QueueTrended requires a start and end date, a reportsuite ID, a character vector of elements and a character vector of metrics.
date.from <- "2014-01-01"
date.to <- "2014-01-07"
reportsuite.id <- "your_report_suite"
metrics <- c("visits","uniquevisitors","pageviews","event10")
elements <- c("page","geoCountry","geoCity")
report.data <- QueueTrended(reportsuite.id, date.from, date.to, metrics, elements)
You may also wish to set any of the 7 optional named parameters. As with QueueRanked the 1.4 API only supports selected for the first element specified.
date.from <- "2014-01-01"
date.to <- "2013-01-07"
reportsuite.id <- "your_report_suite"
metrics <- c("visits","uniquevisitors","pageviews","event10")
elements <- c("page","geoCountry","geoCity")
top <- 100
start <- 100
selected <- list(page=c("Home","Search","About"))
date.granularity <- "hour"
segment.id <- "dw:12345"
data.current <- TRUE
expedite <- TRUE
report.data <- QueueTrended(reportsuite.id, date.from, date.to, metrics,elements,top=top,start=start,selected=selected,segment.id=segment.id,data.current=data.current,expedit=expedite)
Returns a pathing report. This is an ordered list of paths matching the specified pattern.
QueuePathing requires a start and end date, a reportsuite ID, a single element, a single metric and a pattern of element values that defined the path.
date.from <- "2014-01-01"
date.to <- "2014-01-07"
reportsuite.id <- "your_report_suite"
metric <- "pageviews"
element <- "page"
pattern <- c("Home","::anything::","::anything::")
report.data <- QueuePathing(reportsuite.id, date.from, date.to, metric, element, pattern)
Returns a fallout report. This is a pathed list of elements, with fallout values for each.
QueuePathing requires a start and end date, a reportsuite ID, a single element, a character vector of metrics and a character vector of element values that defined the checkpoints.
date.from <- "2014-01-01"
date.to <- "2014-01-07"
reportsuite.id <- "your_report_suite"
metrics <- c("visits","uniquevisitors","pageviews","event10")
element <- "page"
checkpoints <- c("Home","Contact","ThankYou")
report.data <- QueuePathing(reportsuite.id, date.from, date.to, metrics, element, checkpoints)
Using the API, you can retrieve the setup of your report suite and view definitions for evars and sprops, success events, report suites and segments.
Gets valid elements for a report suite for the current user. This list is restricted by optionally specified existing elements, existing metrics and date granularity.
elements.valid <- GetElements("your_report_suite",metrics=c('visitors','pageviews'),elements=c('page','geoCountry'),date.granularity='day')
Gets valid metrics for a report suite for the current user. This list is restricted by optionally specified existing elements, existing metrics and date granularity.
metrics.valid <- GetMetrics("your_report_suite",metrics=c('visitors','pageviews'),elements=c('page','geoCountry'),date.granularity='day')
Gets evar (conversion variable) definitions for the specified report suite(s). Useful to audit or document a report suite or company in Adobe Analytics.
evars <- GetEvars(c("your_prod_report_suite","your_dev_reportsuite"))
Gets sprop (traffic variable) definitions for the specified report suite(s). Useful to audit or document a report suite or company in Adobe Analytics.
props <- GetProps(c("your_prod_report_suite","your_dev_reportsuite"))
Gets success event definitions for the specified report suite(s). Useful to audit or document a report suite or company in Adobe Analytics.
successevents <- GetSuccessEvents(c("your_prod_report_suite","your_dev_reportsuite"))
Gets all report suites for the company.
reportsuites <- GetReportSuites()
Gets a list of segments for the specified report suites. Useful to find segment IDs for use in reporting helper functions or JSON report definitions.
segments <- GetSegments(c("your_prod_report_suite","your_dev_reportsuite"))