• English
  • MediaWiki:Common.js: Difference between revisions

    Jump to navigation Jump to search
    no edit summary
    (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>
    });

    Navigation menu

    Guest