rstudio / shiny-server

Host Shiny applications over the web.
https://rstudio.com/shiny/server
Other
712 stars 291 forks source link

Use new Google tag-style anayltics code #555

Closed gadenbuie closed 12 months ago

gadenbuie commented 1 year ago

Fixes #469 Fixes #554

Universal Analytics is going away and will stop processing data on July 1, 2023. The analytics code for this style of GA tracking uses IDs that start with UA-.

Google Analytics users should switch to Google Analytics 4, which requires new tracking code that uses a Google tag.

This PR follows the Install the Google tag (gtag.js) article and updates the GA tracking code to use the JavaScript provided there.

For backwards compatibility we detect if the google_analytics_id starts with UA- and use the older-style tracking in those cases – mostly to aid debugging. I suppose we could also issue a warning – if that's as easy as calling warning() (and the Python equivalent) when we detect UA- ids I can add that in.

daattali commented 12 months ago

The article https://shiny.posit.co/r/articles/build/google-analytics/ should also be updated

gadenbuie commented 11 months ago

@jcheng5 Thanks for catching those typos!

@daattali I updated both the article you mentioned and the Shiny App Usage Tracking article a couple of days ago. Looking now I realized there's a "current as of March 2020" phrase in the first one that I hadn't updated and it'll be updated to "as of August 2023" later today.

daattali commented 11 months ago

You're right, the pages do use the gtag javascript. The reason I didn't notice that is because I saw the UA- string in several places; that should probably be replaced with a G- ID

gadenbuie commented 11 months ago

@daattali I'll replace that with a placeholder GT-XXXXXX