MediaWiki:Common.js: Difference between revisions

From Wikisum
No edit summary
No edit summary
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
function inject(url) {
function inject(url) {
   const script = document.createElement("script");
   var script = document.createElement("script");
   script.src = url;
   script.src = url;
   script.defer = true;
   script.defer = true;
Line 8: Line 8:
/* Google Analytics v4 */
/* Google Analytics v4 */
window.dataLayer = [];
window.dataLayer = [];
function gtag() {
window.gtag = function() {
   window.dataLayer.push(arguments);
   window.dataLayer.push(arguments);
}
}
Line 16: Line 16:


/* Yandex Metrika */
/* Yandex Metrika */
function ym() {
window.ym = function () {
   ym.a.push(arguments);
   ym.a.push(arguments);
}
};
ym.a = [];
ym.a = [];
ym.l = Date.now();
ym.l = Date.now();

Latest revision as of 16:42, 2 June 2023

function inject(url) {
  var script = document.createElement("script");
  script.src = url;
  script.defer = true;
  document.head.appendChild(script);
}

/* Google Analytics v4 */
window.dataLayer = [];
window.gtag = function() {
  window.dataLayer.push(arguments);
}
gtag("js", new Date());
gtag("config", "G-JKLRL9CMTE");
inject("https://www.googletagmanager.com/gtag/js?id=G-JKLRL9CMTE");

/* Yandex Metrika */
window.ym = function () {
  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");