Add Matomo Analytics
Summary
We want to be able to track how many people are using Go. Our other projects Schedules and What's Open use Matomo to do this, so let's add it to Go too.
Matomo works by running some JavaScript code on every Go 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
go/templates/layouts/base.html
. Add the following code before the close of the head
section.
<!-- 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', '4']);
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 -->