MediaWiki:Common.js: Difference between revisions
Jump to navigation
Jump to search
no edit summary
JEstarisCJJT (talk | contribs) (Adding Google Analytics Tag Manager integration) |
JEstarisCJJT (talk | contribs) No edit summary |
||
| Line 9: | Line 9: | ||
} | } | ||
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 || []; | 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'); | ||
}); | |||