I refer to the below link which explains how to extract information of Shiny Server application with Google Analytics:
https://shiny.rstudio.com/articles/google-analytics.html
(1) I would like to know if my Shiny Server application has a login page with Username and Password, and I would like to track each different Username's activities, is that possible? Are there any good examples?
(2) Also, I see the code provided for the google-analytics.js as below:
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();
a=s.createElement(o), m=s.getElementsByTagName(o)[0];
a.async=1;
a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-54514964-1', 'auto');
ga('send', 'pageview');
</script>
However, the newer version of Google Analytics generates below for me:
window.dataLayer = window.dataLayer || ;
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-146042456-1');
So which should I follow? the new one or the older one?