我有一个很好的整理R闪亮(shinydashboard)应用程序在服务器上运行。我希望能够跟踪其使用情况,并知道谷歌分析是一个很好的解决方案。但是我遇到了一个设置它的问题。谷歌分析闪亮仪表板应用程序
我试图在这里描述https://shiny.rstudio.com/articles/google-analytics.html
他们认为含有从谷歌全球网站标签的谷歌,analytics.js的脚本的创作方向如下:
<!-- Global Site Tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-4XXXXX5-2">
</script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-4XXXXX5-2');
</script>
然后,他们认为,这种“ google-analytics.js“脚本文件在闪亮的应用程序标题中调用,如下所示:
#ui.r
library(shiny)
shinyUI(fluidPage(
tags$head(includeScript("google-analytics.js")),
includeCSS("cerulean.css"),
titlePanel("Sunlight in the US"),
但是因为我正在使用shin Ÿ仪表盘我的闪亮布局不同...
#ui.r
library(shiny)
library(shinydashboard)
dashboardPage(
dashboardHeader(title = "Single Cell Database"),
dashboardSidebar(
sidebarMenu(
menuItem("P15 Clustering", tabName = "P15_Cluster", icon = icon("th")),
menuItem("P15 Violin Plots", tabName = "P15_Violin", icon = icon("th"))
)),
dashboardBody(
tabItems(
tabItem(tabName = "P15_Cluster",
我似乎无法弄清楚在何处放置...
tags$head(includeScript("google-analytics.js")),
......在闪亮的仪表盘格式。另外,由于googles代码格式不再与示例相匹配,我不相信脚本函数的新格式。
任何有关如何在闪亮的仪表板标题中调用“google-analytics.js”脚本或如何格式化“google-analytics.js”文件中的代码的帮助或建议将非常感谢!