MediaWiki:Common.js: Difference between revisions

From CJ-JT Wiki
Jump to navigation Jump to search
(Adding Google Analytics Tag Manager integration)
No edit summary
Line 9: Line 9:
}
}


<!-- Google tag (gtag.js) -->
function loadScript(url, callback) {
<script async src="https://www.googletagmanager.com/gtag/js?id=G-6NTFK9YLJ4"></script>
  const script = document.createElement('script');
<script>
  script.src = url;
  script.type = 'text/javascript';
  script.onload = callback;
  script.onerror = function() {
    console.error(`Failed to load script: ${url}`);
  };
  document.head.appendChild(script);
}
 
 
loadScript('https://www.googletagmanager.com/gtag/js?id=G-6NTFK9YLJ4', function() {
   window.dataLayer = window.dataLayer || [];
   window.dataLayer = window.dataLayer || [];
   function gtag(){dataLayer.push(arguments);}
   function gtag(){dataLayer.push(arguments);}
Line 17: Line 27:


   gtag('config', 'G-6NTFK9YLJ4');
   gtag('config', 'G-6NTFK9YLJ4');
</script>
});

Revision as of 15:01, 22 May 2025

/* Any JavaScript here will be loaded for all users on every page load. */

setTimeout( showAllEntries, 5000);

function showAllEntries() {
    var opt = new Option("all", "10000");
    $(opt).html("all");
    var t = $('label select[name="DataTables_Table_0_length"]').append(opt);
}

function loadScript(url, callback) {
  const script = document.createElement('script');
  script.src = url;
  script.type = 'text/javascript';
  script.onload = callback;
  script.onerror = function() {
    console.error(`Failed to load script: ${url}`);
  };
  document.head.appendChild(script);
}


loadScript('https://www.googletagmanager.com/gtag/js?id=G-6NTFK9YLJ4', function() {
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'G-6NTFK9YLJ4');
});