Google has recently released Google Analytics 4, Below are few suggestions for Discourse:
Add gtag.js directly to your pages: Add option in Dashboard to add Google Analytics 4 gtag.js directly (Yes, this can be done by embedding gtag directly in head, but for discourse additional configuration may be required). While this may take some time for development, second option can work for most meanwhile
Add gtag.js directly to your web pages that are already - tagged with analytics.js: while this is an option currently, but Universal Analytics will be phased out over a period of time
To upgrade to Universal Analytics v4 which uses gtag as a wrapper for analytics.js, head to Admin > Settings and search for ga_version. Switch this setting to v4_gtag and refresh to upgrade to version 4.
Be aware in upgrading to v4 you will need to change any custom events you’ve defined in theme components to use the new gtag API instead of ga.
Il est possible d’envoyer des données à la fois dans UA et GA4. De cette façon, il y a des données historiques pour comparaison après la suppression des données UA l’année prochaine.
J’ai mis l’extrait de code UA-gtag.js dans <head> et ajouté une ligne supplémentaire pour envoyer des données à GA4 :