Matomo with Foswiki
Adding the open source visitor analytics tool
Matomo to foswiki requires adding a bit of javascript on every page. This can be easily accomplished through Foswiki's template system:
- In your Foswiki installation, create a file templates/foswiki.matomo.tmpl, add the following content:
%TMPL:INCLUDE{"foswiki"}%
%ADDTOZONE{"head" id="ingress" text="
<!-- Matomo -->
<script type='text/javascript'>
var _paq = window._paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u='//analytics.yourmatomo.net/';
_paq.push(['setTrackerUrl', u+'matomo.php']);
_paq.push(['setSiteId', '123']);
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+'matomo.js'; s.parentNode.insertBefore(g,s);
})();
</script>
<noscript><p><img src='//analytics.yourmatomo.net/matomo.php?idsite=123&rec=1' style='border:0;' alt='' /></p></noscript>
<!-- End Matomo Code -->
"}%
- The bit between '<!-- Matomo -->' and '<!-- End Matomo Code -->' is the tracking code from your Matomo installation
- Make sure to change all double quotes (") to single quotes (') in the matomo code
- Now go to your DefaultPreferences topic, and modify this line:
- Set SKIN = natedit,pattern
- so that it says:
- Set SKIN = matomo,natedit,pattern
That's it!
--
KoenMartens - 22 Jun 2019