Wednesday, 19 June 2019

Shiny tabPanel and Google Analytics

I've read myself through the great tutorial here. However, my knowledge of jQuery equals to zero. I use several tabPanels in my ShinyApp to display my data. The tutorial explains how to track link-clicking events (which works fine, I included a .js as explained in the tutorial). Is there a way to track if users click on a specific tabPanel (for example Panel1 and Panel2)? I've tried to do the same with a link referring to external sources, but that does not work.

tabsetPanel(
tabPanel("Panel1", showOutput("PlotPanel1", 'dimple')),
tabPanel("Panel2", showOutput("PlotPanel2", 'dimple')))

Edit:

I guess I have to include some code in my analytics.js file. Therefore I tried several things, but frankly without knowledge of jQuery, this is just wrong. Can anyone help here?

$( ".selector" ).tabs({
  on('option', 'click', function(l) {
  ga('send', 'event', 'tabPanel', 'tabPanel', $(l.currentTarget).val());
  }
});

Thanks.



from Shiny tabPanel and Google Analytics

No comments:

Post a Comment