Shiny and Google Analytics, navbarPage not initialized


I just built my first shiny app and everything is working great. I setup my own shiny server, mapped the URL with apache2 using a reverse proxy for port forwarding. I have tested and validated that users can connect and use the app. Next, I wanted to use Google Analytics to integrate some metrics on the app.

I followed this article:

I created an account, added a property then got my analytics js to add in.

I saved it to a single file google-analytics.html as the example states. It contains the script links and boiler plate you copy / paste from google.

Then, I add the first line in my UI portion of my app.R


The rest of the app contained a tab panel nav set. Without the analytics code, the app would automatically open the content of the first of three tabs.

The analytics code is appearing correctly in the section of the rendered HTML. However, the UI is building a FOURTH tab before the other three that has NO content and makes it appear that the app has not started.

Any ideas?

My overall UI follows the following form:

ui <- navbarPage(

tags$head(includeHTML(("google-analytics.html"))), # breaks the code when adding this line!

title="Data Explorer",


... data section ...        

... analysis section ...
tabPanel("Power Test",

        # input...
        # output...

)strong text

I had the same issue. One simple workaround is to set the "selected" argument of shiny::navbarPage() to the desired landing tab. That stops the app from defaulting to the invisible fourth tab.

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.