FEATURE: Upgrade analytics.js to gtag.js (PR #10893)

Per Google, sites are encouraged to upgrade from analytics.js to gtag.js for Google Analytics tracking.

This PR makes this change for Discourse sites going forward.

Note it’s in draft status, so testing is not yet completed nor UI copy changes to coincide. I’d love some feedback on my approach first.

GitHub

Are we including the gtag script even if the site setting is empty?

No this partial gets loaded only if the site setting is present.

Looks good.

@pmusaraj I made a couple additional changes (changed CSP URL for GA script with associated test, and copy). Mind having another review?

:+1:

Per Google, sites are encouraged to upgrade from analytics.js to gtag.js for Google Analytics tracking. This commit updates core Discourse to use the new gtag.js API Google is asking sites to use. This API has feature parity with analytics.js but does not use trackers.