Ir para o conteúdo

MediaWiki:Common.js: mudanças entre as edições

De WikiMaanaim
Criou página com 'Códigos JavaScript aqui colocados serão carregados por todos aqueles que acessarem alguma página deste wiki: mw.loader.load("https://www.googletagmanager.com/gtag/js?id=G-K10YXH7MPV"); window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'G-K10YXH7MPV');'
 
Sem resumo de edição
 
(3 revisões intermediárias pelo mesmo usuário não estão sendo mostradas)
Linha 1: Linha 1:
/* Códigos JavaScript aqui colocados serão carregados por todos aqueles que acessarem alguma página deste wiki */
/* Códigos JavaScript aqui colocados serão carregados por todos aqueles que acessarem alguma página deste wiki */
mw.loader.load("https://www.googletagmanager.com/gtag/js?id=G-K10YXH7MPV");
if (mw.config.get('wgUserName') === null) {


window.dataLayer = window.dataLayer || [];
  mw.loader.load("https://www.googletagmanager.com/gtag/js?id=G-K10YXH7MPV");
function gtag(){dataLayer.push(arguments);}
 
gtag('js', new Date());
  window.dataLayer = window.dataLayer || [];
gtag('config', 'G-K10YXH7MPV');
  window.gtag = function(){ dataLayer.push(arguments); };
 
  gtag('js', new Date());
  gtag('config', 'G-K10YXH7MPV');
 
}
 
document.addEventListener('click', function(e) {
  var link = e.target.closest('a');
  if (!link) return;
 
  if (link.hostname !== location.hostname) {
    gtag('event', 'click_externo', {
      'event_category': 'link',
      'event_label': link.href
    });
  }
});
 
document.addEventListener('click', function(e) {
  var link = e.target.closest('a');
  if (!link) return;
 
  if (link.href.match(/\.(pdf|zip|doc|jpg)$/i)) {
    gtag('event', 'download', {
      'event_category': 'arquivo',
      'event_label': link.href
    });
  }
});

Edição atual tal como às 20h58min de 26 de março de 2026

/* Códigos JavaScript aqui colocados serão carregados por todos aqueles que acessarem alguma página deste wiki */
if (mw.config.get('wgUserName') === null) {

  mw.loader.load("https://www.googletagmanager.com/gtag/js?id=G-K10YXH7MPV");

  window.dataLayer = window.dataLayer || [];
  window.gtag = function(){ dataLayer.push(arguments); };

  gtag('js', new Date());
  gtag('config', 'G-K10YXH7MPV');

}

document.addEventListener('click', function(e) {
  var link = e.target.closest('a');
  if (!link) return;

  if (link.hostname !== location.hostname) {
    gtag('event', 'click_externo', {
      'event_category': 'link',
      'event_label': link.href
    });
  }
});

document.addEventListener('click', function(e) {
  var link = e.target.closest('a');
  if (!link) return;

  if (link.href.match(/\.(pdf|zip|doc|jpg)$/i)) {
    gtag('event', 'download', {
      'event_category': 'arquivo',
      'event_label': link.href
    });
  }
});