discourse/app/assets/javascripts/discourse/scripts/google-universal-analytics-v4.js
David Taylor a084680f1d
DEV: Pass static scripts through Ember CLI (#17373)
All files under `app/assets/javascripts/scripts` will be run through babel, given sourcemaps, and output under `/assets/{name}.js`. This is another step towards removing our sprockets dependence.
2022-07-08 10:13:46 +01:00

26 lines
653 B
JavaScript

(function () {
const gaDataElement = document.getElementById("data-ga-universal-analytics");
window.dataLayer = window.dataLayer || [];
window.gtag = function () {
window.dataLayer.push(arguments);
};
window.gtag("js", new Date());
let autoLinkConfig = {};
if (gaDataElement.dataset.autoLinkDomains.length) {
const autoLinkDomains = gaDataElement.dataset.autoLinkDomains.split("|");
autoLinkConfig = {
linker: {
accept_incoming: true,
domains: autoLinkDomains,
},
};
}
window.gtag("config", gaDataElement.dataset.trackingCode, {
send_page_view: false,
autoLinkConfig,
});
})();