Closed gadenbuie closed 12 months ago
The article https://shiny.posit.co/r/articles/build/google-analytics/ should also be updated
@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.
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
@daattali I'll replace that with a placeholder GT-XXXXXX
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 withUA-
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 callingwarning()
(and the Python equivalent) when we detectUA-
ids I can add that in.