-
Notifications
You must be signed in to change notification settings - Fork 71
/
ui.R
174 lines (154 loc) · 10.8 KB
/
ui.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# This is the user-interface definition of a Shiny web application.
# You can find out more about building applications with Shiny here:
#
# http://shiny.rstudio.com
#
library(shiny)
library(shinydashboard)
library(dygraphs)
library(d3heatmap)
scriptHeaders <- function(inputId=NULL) {
tagList(
singleton(tags$head(tags$script(src = "js/gtm.js")))
)
}
dashboardPage(skin = "purple",
dashboardHeader(title = "GA Dashboard"),
dashboardSidebar(
sidebarMenu(
menuItem("Dashboard", tabName = "dashboard", icon=icon("dashboard")),
menuItem("Upload Data", tabName = "join", icon=icon("cloud-upload")),
menuItem("Analyse", tabName = "analyse", icon=icon("calculator")),
menuItem("Github Source Code", href="https://github.com/MarkEdmondson1234/ga-dashboard-demo", icon = icon("github")),
menuItem("How To Guide", href="http://markedmondson.me/enhance-your-google-analytics-data-with-r-and-shiny-free-online-dashboard-template", icon=icon("info-circle")),
menuItem("Say Hello :-", href="#", newtab=F),
menuSubItem("@HoloMarkeD", href="http://twitter.com/HoloMarkeD", icon = icon("twitter")),
menuSubItem("LinkedIn", href="http://dk.linkedin.com/in/markpeteredmondson", icon = icon("linkedin")),
menuSubItem("Blog", href="http://markedmondson.me/?utm_source=shinyapps&utm_medium=referral&utm_content=sidebar&utm_campaign=ga-dash-demo", icon=icon("hand-o-right")),
menuItem("Other Apps :-", href="#", newtab=F),
menuSubItem("GA Effect", href="https://gallery.shinyapps.io/ga-effect/", icon = icon("line-chart")),
menuSubItem("GA Rollup", href="https://mark.shinyapps.io/ga-rollup/", icon = icon("area-chart")),
menuSubItem("GA Meta", href="https://mark.shinyapps.io/ga-meta/", icon = icon("sitemap"))
)
),
dashboardBody(
tabItems(
# first tab content
tabItem(tabName = "dashboard",
h1("Executive Summary"),
fluidRow( #row 1
scriptHeaders(),
box(width=6, height="200px",title="Select Data", solidHeader = T, status = "primary",
selectInput("medium_select",
"Select Traffic Channel",
choices = c("All" = "total",
"Direct" = "(none)",
"Email" = "email",
"SEO" = "organic",
"Referral" = "referral",
"Social" = "social")),
helpText("Select which channel to show in the plots below. For demo purposes it loads sessions, but could easily be revenue, goals or other metrics and segments.")
),
box(width=6, height="200px",title = "What is this?", solidHeader = T, status = "info",
p("This is a demo Google Analytics dashboard using R, Shiny and various other features."),
p("Check out the source code via the Github link to the left. ")
)
),
h2(" Top Level Trends"),
fluidRow(
valueBoxOutput("WoW"),
valueBoxOutput("MoM"),
valueBoxOutput("YoY")
),
h2("Plots"),
fluidRow(
tabBox(title = "", width=12,
tabPanel(title=tagList(shiny::icon("line-chart"), "Trend"),
helpText("Click and drag on the plot to zoom and select date ranges. Events that have been uploaded to the MySQL backend are shown as dotted lines, and unusual time points are annotated below them."),
selectInput("agg_select",
"Select Trend Type",
choices = c("Day" = "day",
"Week" = "week",
"Month" = "month",
"Annual" = "year"),
selected = "week"
),
textOutput("date_shown"),
dygraphOutput("plot1", height = "600px")
),
tabPanel(title=tagList(shiny::icon("calendar"), "Day Of Week"),
helpText("Zoom in by selecting with the mouse. This heatmap representation of the data helps show if the day of the week holds any patterns."),
textOutput("current_week"),
d3heatmapOutput("heatmap", height="800px")
),
tabPanel(title=tagList(shiny::icon("thumbs-up"), "Event Impact"),
helpText("The estimated impact of the events on total sessions for two weeks is shown below, as well as if the impact can be considered statistically significant. Get more detail in the analysis section."),
plotOutput("CausalPlotSummary")
)
) #tabBox
)
),
# second tab content
tabItem(tabName = "join",
h1("Import Data to Join"),
fluidRow(
box(height="200px",
title = "Upload file",
solidHeader = T,
status ="primary",
fileInput("eventUploadFile",
"Marketing Events",
accept = c("text/csv", ".csv")),
helpText("Upload a CSV file with two columns: date (YYYY-MM-DD) and eventname (string), to store it in the database. 0.5MB limit.")),
box(height="200px",
title = "Public Upload", solidHeader=T, status="info",
p("For this demo, anyone can load up data into the MySQL database which will appear in the table below. This data is persistent between Shiny app sessions."),
p("These events are then used in the trend graphs and in the Analyse section. Other applications include uploading CRM data, offline transactions or campaign info to bind to your GA data.")
),
box(width = 12, solidHeader = T, status="success",
title = "Current Data Loaded",
DT::dataTableOutput("eventTable")
)
)
),
# third tab content
tabItem(tabName = "analyse",
h2("Deepdive Analysis"),
helpText("This section demonstrates some R packages that work with time-series data. This leverages the strength of using R for dashboarding. "),
tabBox(title = "Select Analysis", width = 12,
tabPanel(title = tagList(shiny::icon("thumbs-up"), "Event Effects"),
helpText("The estimated impact of the uploaded events on total traffic is shown below. It uses code similar to the GA Effect app linked in the menu to the left."),
uiOutput("multiple_plots")
), # tabPanel1
tabPanel(title = tagList(shiny::icon("exclamation"), "Anomaly Detection"),
helpText("What dates had unusual activity? This uses Twitter's AnomalyDetection package to find unusual activity. Fine tune the dates shown using the controls below."),
selectInput("medium_select2",
"Select Plot Channel",
choices = c("All" = "total",
"Direct" = "(none)",
"Email" = "email",
"SEO" = "organic",
"Referral" = "referral",
"Social" = "social")
),
selectInput("agg_select2",
"Select Plot Date Type",
choices = c("Day" = "day",
"Week" = "week",
"Month" = "month"),
selected = "day"
),
sliderInput("max_anoms",
"Sensitivity",
min=0.0,
max=0.4,
value = 0.1,
step = 0.05),
plotOutput("anomalyPlot"),
DT::dataTableOutput("anomalyTable")
) # tabPanel2
) #tabBox
)
)
)
)