Difference between revisions of "MediaWiki:Common.js"

From PRA-Info
Jump to navigation Jump to search
(Created page with "→‎Any JavaScript here will be loaded for all users on every page load.: $(document).ready(function() { var pageBase = document.getElementById('content'); pageBase.innerHTML...")
 
 
Line 1: Line 1:
 
/* Any JavaScript here will be loaded for all users on every page load. */
 
/* Any JavaScript here will be loaded for all users on every page load. */
 
$(document).ready(function() {
 
$(document).ready(function() {
var pageBase = document.getElementById('content');
+
var gscript = document.createElement( 'script' );
pageBase.innerHTML = pageBase.innerHTML + "\n" + "<!-- Google tag (gtag.js) --> <script async src=\"https://www.googletagmanager.com/gtag/js?id=G-5V1LKDM2DY\"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'G-5V1LKDM2DY'); </script>";
+
gscript.setAttribute( 'src', 'https://www.googletagmanager.com/gtag/js?id=G-5V1LKDM2DY' );
 
+
gscript.async = true;
 +
$("head").append(gscript);
 +
var gscript2 = document.createElement( 'script' );
 +
gscript2.innerHTML = "window.dataLayer = window.dataLayer || [];" + "\n" +
 +
  "function gtag(){dataLayer.push(arguments);}" + "\n" +
 +
  "gtag('js', new Date());" + "\n" +
 +
  "gtag('config', 'G-5V1LKDM2DY')\;" ;
 +
$("head").append(gscript2);
 
});
 
});

Latest revision as of 13:33, 8 September 2023

/* Any JavaScript here will be loaded for all users on every page load. */
$(document).ready(function() {
var gscript = document.createElement( 'script' );
gscript.setAttribute( 'src', 'https://www.googletagmanager.com/gtag/js?id=G-5V1LKDM2DY' );
gscript.async = true;
$("head").append(gscript);
var gscript2 = document.createElement( 'script' );
gscript2.innerHTML = "window.dataLayer = window.dataLayer || [];" + "\n" +
  "function gtag(){dataLayer.push(arguments);}" + "\n" +
  "gtag('js', new Date());" + "\n" +
  "gtag('config', 'G-5V1LKDM2DY')\;" ;
$("head").append(gscript2);
});