MediaWiki:Common.js: Difference between revisions
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
function inject(url) { | function inject(url) { | ||
const script = document.createElement("script"); | |||
script.src = url; | |||
document.head.appendChild(script); | script.async = true; | ||
script.onerror = function () { | |||
console.error(`Error loading script: ${url}`); | |||
}; | |||
document.head.appendChild(script); | |||
} | } | ||
/* Google Analytics v4 */ | /* Google Analytics v4 */ | ||
const dataLayer = []; | |||
function gtag() { | function gtag() { | ||
dataLayer.push(arguments); | |||
} | } | ||
gtag("js", new Date()); | |||
gtag("config", "G-JKLRL9CMTE"); | |||
inject("https://www.googletagmanager.com/gtag/js?id=G-JKLRL9CMTE"); | |||
/* Yandex Metrika */ | |||
function ym() { | |||
ym.a.push(arguments); | |||
} | |||
ym.a = []; | |||
ym.l = Date.now(); | |||
ym(93598126, "init", { | |||
clickmap: true, | |||
trackLinks: true, | |||
accurateTrackBounce: true | |||
}); | |||
inject("https://mc.yandex.ru/metrika/tag.js"); |
Revision as of 15:10, 16 May 2023
function inject(url) { const script = document.createElement("script"); script.src = url; script.async = true; script.onerror = function () { console.error(`Error loading script: ${url}`); }; document.head.appendChild(script); } /* Google Analytics v4 */ const dataLayer = []; function gtag() { dataLayer.push(arguments); } gtag("js", new Date()); gtag("config", "G-JKLRL9CMTE"); inject("https://www.googletagmanager.com/gtag/js?id=G-JKLRL9CMTE"); /* Yandex Metrika */ function ym() { ym.a.push(arguments); } ym.a = []; ym.l = Date.now(); ym(93598126, "init", { clickmap: true, trackLinks: true, accurateTrackBounce: true }); inject("https://mc.yandex.ru/metrika/tag.js");