Logging Shiny app usage with Rstudio connect

shiny
rstudioconnect

#1

Hi all,

Any tips on how best to track usage of shiny apps using RStudio Connect?

At a minimum I would like to know who used my shiny apps, when the used them and if they had any issues.

Thanks

Iain


#2

Hi @iain,

It isn’t RStudio-Connect-specific, but have you looked at @slopp’s Shiny App Usage Tracking article?
https://shiny.rstudio.com/articles/usage-metrics.html
It has sample code for user tracking in JS, for Google Analytics, and Piwik.


#3

@mara, thanks - I hadn’t seen the section on user id tracking before. I will have to find out if I am allowed to use google analytics (or similar) behind our corporate fire wall.


#4

Behind a firewall on corporate usage, you can use piwik hosting it on your own corporate server.
A good solution when you don’t want or can’t use google. Example of code for shiny as in the article previously cited.


#5

Iain, We are also working on capturing usage metrics as a generic feature in RStudio Connect. The article referenced in this thread provides a way to capture detailed information about how users are interacting within an application. However, we are hoping Connect can capture generic information across applications such as: who visited and for how long.

If we did capture these metrics, what would be a useful output format for your use case? Would writing them to a csv file be sufficient?


#6

@slopp, that would be great.

A csv file would be sufficient if I was able to download the csv file from the Admin console.


#7

Is this planned to be by applications log or aimed towards rstudio admin?
As I am playing the second role, I can say it can be very useful to have this informations for all apps in a dashboard. It is something I missed currently. We can follow application process but not users connections. I wanted to install something like piwik.

Also as we tend to make our developer responsible for their apps,so they are instested in that information for their on shiny application. To follow number of connections, when and who.

Csv or json format is fine I think.


#8

Speaking as a developer without admin rights, I would really like to be able to see what users (and which ones) are doing with my apps. Knowing (generally) who has tried out an app and how much time they’ve spent should be able to help the us get ahead of client questions/issues. (Ideally I’d like timestamps of what inputs clients are changing. Specifically are they uploading files or customizing certain defaults. Ie: If I have a field defaulting to 13 but everyone changes it to 52, maybe the default should be changed)

I can’t see our server admin having the time to analyze logs for this info. Even if they did have the time, they aren’t likely to be up to speed on the specifics of project x or interested in stakeholder ys actions before meeting z.


#9

@cderv, this worked brilliantly.

FYI - this was a very useful guide for setting it all up.
https://mediatemple.net/community/products/dv/213195403/install-piwik-on-ubuntu-14.04


#10

One final question on this topic :slight_smile:

How would one track the row selection event? For example, in the example app https://yihui.shinyapps.io/DT-rows/ how could I track that “Duster 360” was selected in the x3 table? It is row 7

It isn’t clear to me what the row selection event to modify this code snippet from @slopp great tutorial:

tags$script(HTML(
"$(document).on(‘shiny:inputchanged’, function(event) {
if (event.name === ‘bins’ || event.name === ‘col’) {
_paq.push([‘trackEvent’, ‘input’,
‘updates’, event.name, event.value]);
}
});"

Any tips greatly appreciated.


#11

An alternative to the client side tracking that Google Analytics offers is to track it in Google Analytics server side. It has a measurement protocol that lets you construct the analytics hit yourself, and has the advantage of triggering on code or reactive selection, rather than web events. A combo of the two should cover all cases.

A development version of a package that lets you do this is googleMeasureR.


#12

FYI - I have posted a follow up question on Stackoverflow,
https://stackoverflow.com/questions/46963920/issue-capturing-non-numeric-fields-using-piwik-for-shiny

(tracking user interaction is very interesting!)


#13

Agree with all of the above, a simple csv or json of usage statistics would be sufficient. Being able to manually download from the admin console is a good option, being able to programmatically pull the data and build a shiny app to dig around that data would be a great option. Maybe if the data were stored in a sqlite db on the connect server, we could even build a streaming view of content usage statistics. :open_mouth:


#14

FYI - just added a bounty :slight_smile:


#15

I think it would be great to not just have it as exportable but on an aggregate level inside of RStudio Connect so that we can show internal management folks how popular the different applications/reports we are building are!


#16

To close the loop on this, I wasn’t able to get this to work with Piwik but was able to generate a work around with Google analytics.

By modifying Sean’s code slightly I was able to get desired view in the “User Report” window. The trick was that eventValue can only be a positive number but the eventAction can be a string.

Code

$(document).on('shiny:inputchanged', function(event) {
if(event.name == 'bins' || event.name == 'col'){
my_value = event.name + "_" + event.value;
   console.log(my_value);
ga('send', {
hitType: 'event',
eventCategory: 'inputs',
eventAction: my_value,
});   
}
});

Screen shot of User Report


#17

Any movement on this feature? We would love to report to management our ROI on our Rstudio Connect investment.


#18

Hi Rochelle,

We absolutely want you to be able to show management a ROI for Connect! The upcoming 1.6.0 version of Connect, scheduled for release in the next two weeks, will include two new charts in the admin dashboard that show high-level user activity over time. We're also working on the more detailed event tracking discussed in this thread (along the lines of who is visiting content and when). The more detailed event tracking is scheduled for an upcoming release, but the timeframe for that release is still being determined.

Let us know if you have any specific metrics you'd be interested in collecting.

Best,

Sean


#19

If I were to envision the reporting structure I'd like to report on from our RStudio Connect deployment it would be along the lines of:
-Unique visitors to each app per day
-Unique visits to each app per day
-Total time on page for each app per day
This is probably more than is planned for the initial release, but even if you made the data available for us to query, we could then report on the raw data.

Looking forward to the new version!