I have been trying to get Matomo to work with a shiny app that uses shinydashboard and particularly dashboardPage but cannot get it to work. has anyone had success doing this?
I have tried using Sean Lopp's code (https://shiny.rstudio.com/articles/usage-metrics.html). This works with a fluidPage but not with the dashboardPage.
If, instead of using dashboardPage as in the code below I use fluidPage I get the result I want and can see the tracker working.
When using this code I get the following error:
Error in tagAssert(header, type = "header", class = "main-header") :
Expected tag to be of type header
I have tried inserting the tags$head(HTML())) chunk in the dashboardHeader() and get the same error. If I place it immediately after the dashboardHeader I get:
Error in tagAssert(sidebar, type = "aside", class = "main-sidebar") :
Expected tag to be of type aside
This is an example of the code with dashboardPage. The identical code but with dashboardPage replaced with fluidPage works.
I would be grateful for any suggestions that anyone might have.
Thanks
library(shiny)
library(shinydashboard)
ui <- dashboardPage(
tags$head(HTML(
"<script type='text/javascript'>
var _paq = _paq || [];
/* tracker methods like 'setCustomDimension' should be called before 'trackPageView' */
_paq.push(['setDocumentTitle', document.domain + '/' + document.title]);
_paq.push(['setCookieDomain', '#########']);
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u='###############################';
_paq.push(['setTrackerUrl', u+'piwik.php']);
_paq.push(['setSiteId', '9']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
})();
</script>"
)),
dashboardHeader(title = "THIS IS A HEADER"),
dashboardSidebar(),
dashboardBody(),
title = "Dashboard example"
)
# Define server logic required to draw a histogram
server <- function(input, output) {
}
# Run the application
shinyApp(ui = ui, server = server)