Adding a Sexy UI to RSiteCatalyst using Shiny

Before we begin, it is important to mention that we have long been strong supporters of the work that Randy Zwitch, Willem Paling & Jowanza Joseph have done to create and maintain the extremely powerful Adobe Analytics R Package, RSiteCatalyst. Their dedication to this open-source effort often goes unrecognized which, as the idea of using programmatic analysis for digital analytics data becomes a more accepted practice, we hope will change.

While we, and countless others, have found the ability to programmatically prepare, manipulate, and analyze Adobe Analytics data using the RSiteCatalyst package insanely valuable, we also found that there was much greater value to be had if only we could expose the power of programmatic data analysis to a broader audience.

The question then became, how can we bring the power of R to decision makers that aren’t being paid to program in R? The answer, a sexy UI of course!

To help illustrate how you can leverage the Shiny UI framework in combination with the RSiteCatalyst package, we have developed a very basic application to walk you through the steps. So while you may find yourself saying ‘I can do all of this much easier inside Adobe Analytics or Excel’ remember that this example is meant to serve as a starting point for building more complex applications that provide functionality that would be very difficult, if not impossible, to accomplish using those other applications.

NOTE: This example assumes that you have the following installed and configured:

  • R
  • RStudio
  • RSiteCatalyst Package
  • Shiny Package

Shiny applications have two primary components, a user-interface file (ui.R) that defines the look & feel of the application and a server script (server.R) that contains all of the R code the application will leverage.

ui.R

# Load Shiny
library(shiny)

# Define UI for the application
shinyUI(fluidPage(
  
  # Application title
  titlePanel("Adobe Analytics - Report Suite Summary"),
  
  # Sidebar with controls to provide Adobe Analytics API credentials,
  # report suite, and reporting date pickers.
  sidebarLayout(
    sidebarPanel(
      textInput("user", "user:company", ""),
      
      textInput("secret", "shared secret", ""),
      
      textInput("rsid", "report suite", ""),
      
      
      dateInput('dateStart',
      label = 'from: yyyy-mm-dd',
      value = Sys.Date()
      ),
      
      dateInput('dateEnd',
      label = 'to: yyyy-mm-dd',
      value = Sys.Date()
      ),

      actionButton("getRS", "Get Report Suite Summary")
   
    ),
    
    # Show the summary output from RSiteCatalyst
    mainPanel(
		dataTableOutput('summary')
    )   
  )
))

The server-side of the application is shown below and handles the Adobe Analytics API authentication, the report request, and the output sent to the UI.

server.R

# Load Shiny
library(shiny)

# Define server logic required to request summary data from Adobe Analytics
shinyServer(function(input, output) {

  # Load RSiteCatalyst
  library("RSiteCatalyst")

    # Listen for a click on the 'Get Report Suite Summary' button
    observeEvent(input$getRS, {
    
          # Authenticate using the user supplied credentials
	  SCAuth(input$user, input$secret)
	  
          # Builds report reqeust using user inputted parameters
	  date.from

Once you have your ui.R and server.R scripts coded, place them in directory that can be called from RStudio to test your application.

Within RStudio, execute the following:

shiny::runApp(‘PATH_TO_YOUR_APPLICATION_DIRECTORY’)

This will launch your application.

Shiny UI

While the application is running, you can make use of the RStudio Console to monitor the application state.

RStudio Console

If everything worked correctly, the application will output the summary data.

Shiny Data Table
Our hope is that someone will take this basic framework and will be inspired to build a killer application utilizing Shiny and RSiteCatalyst.
REFERNCES:
RSiteCatalyst Technical Reference
Shiny Function Reference
Shiny Sample Applications
RStudio