Add Matomo Analytics
Summary
We want to be able to track how many people are looking at srctweb. Our other projects Schedules and What's Open use Matomo to do this, so let's add it to srctweb too.
Matomo works by running some JavaScript code on every page a user accesses. To do this, we can put
an HTML <script>
tag in the <head>
section. The common layout for every page can be found in the project in the file
srctweb/_includes/head.html
. Add the following code to the end of the file.
<!-- Matomo -->
<script type="text/javascript">
var _paq = _paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="//matomo.srct.gmu.edu/";
_paq.push(['setTrackerUrl', u+'piwik.php']);
_paq.push(['setSiteId', '5']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
})();
</script>
<!-- End Matomo Code -->