Help with adding tracking code to courses hosted on website

Dec 06, 2022

I have a project where we host the modules on a web server (uploaded to cpanel) and the learner accesses them from a different front end. The client has now asked if we can add this tracking code to each "page". If I add a trigger to execute javascript, would I have it trigger on the first slide of each course? And can anyone tell me if this is the code I'd use? 

Tracking Code

Make sure this code is on every page of your website. We recommend pasting it immediately before the closing </head> tag.

<!-- Matomo -->

<script>

  var _paq = window._paq = window._paq || [];

  /* tracker methods like "setCustomDimension" should be called before "trackPageView" */

  _paq.push(['trackPageView']);

  _paq.push(['enableLinkTracking']);

  (function() {

    var u="//removed link for privacy/piwik/";

    _paq.push(['setTrackerUrl', u+'matomo.php']);

    _paq.push(['setSiteId', '1']);

    var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];

    g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);

  })();

</script>

<!-- End Matomo Code -->

1 Reply