Shinyapps + rga

305 views
Skip to first unread message

BadriNarayanan Srinivasan

unread,
Oct 15, 2013, 11:04:21 AM10/15/13
to shiny-...@googlegroups.com
Hey Everyone -

How to use rga (Google Analytics) package within shiny server?

rga - is a package that helps to connect Google Analytics API from R using OAuth 2.0. Wondering whether shiny supports this?

Thanks in advance,
Badri

Jeff Allen

unread,
Oct 16, 2013, 7:20:21 AM10/16/13
to shiny-...@googlegroups.com
Hi Badri,

I'm not familiar with rga, but one well-documented alternative is to use Shiny Server to embed a Google Analytics ID into each app. (see the "google analytics id" section here: http://htmlpreview.github.io/?https://github.com/rstudio/shiny-server/blob/master/config.html#google_analytics_id).

The alternative would be to embed the necessary Javascript in your Shiny application directly. This isn't well-tested or official, but here's an example of doing that in one application: https://github.com/trestletech/shiny-sandbox/blob/master/grn/ui.R#L7. You would obviously want to change the GA ID you're using there.

My suspicion is that the rga package may be used to doing analysis on the traffic you've already collected in GA. So perhaps you'll find it useful after setting up the GA JavaScript on an app using one of the above techniques.

Best,
Jeff

BadriNarayanan Srinivasan

unread,
Oct 16, 2013, 7:44:44 AM10/16/13
to shiny-...@googlegroups.com
Hi Jeff -

I am not sure whether I explained my problem correctly.

I am 'not trying' to implement Google Analytics for my Shiny app.

The application which I want to create should connect to Google Analytics (using rga or other pacakges) of the user and pull the data for analysis. rga uses OAuth 2.0 to connect to the Google Analytics.

Does it make sense?

Thanks,
Badri

Jeff Allen

unread,
Oct 16, 2013, 8:20:37 AM10/16/13
to shiny-...@googlegroups.com
Ah, very good. In that case, there's no reason why you wouldn't be able to leverage this package from within Shiny. Just about anything you can do in R, you can do in a server.R file in Shiny. In the server, it's just R code running in an R process (albeit with some reactive sugar on top).

Jeff

BadriNarayanan Srinivasan

unread,
Oct 16, 2013, 11:59:54 PM10/16/13
to shiny-...@googlegroups.com
Hmmm. Need to figure this one out. It would be so good if I get an example to connect to Google Analytics account from shiny application, can do wonders.
Reply all
Reply to author
Forward
0 new messages