Google Analytics for Shiny Server application with User logon

I refer to the below link which explains how to extract information of Shiny Server application with Google Analytics:

(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:

  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();
  a=s.createElement(o), m=s.getElementsByTagName(o)[0];

  ga('create', 'UA-54514964-1', 'auto');
  ga('send', 'pageview');


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?

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