Skip to content
Snippets Groups Projects

[#12] Add support for Matomo tracking

Open Caetan Tojeiro Carpente requested to merge 12_support_tracking_matomo into master
Files
2
+ 35
0
# Site analytics - Matomo registration
In order to track your site using Matomo web analytics you need to follow these steps.
Please register or sign in to reply
## Request a Matomo website
First of all, you need to open a ticket with the [Matomo team](https://cern.service-now.com/service-portal?id=functional_element&name=web-infrastructure) requesting a Matomo website for your URL. They will reply to you with the JavaScript snippet that needs to be embedded into your site.
    • Comment on lines +6 to +7
      Suggested change
      6 ## Request a Matomo website
      7 First of all, you need to open a ticket with the [Matomo team](https://cern.service-now.com/service-portal?id=functional_element&name=web-infrastructure) requesting a Matomo website for your URL. They will reply to you with the JavaScript snippet that needs to be embedded into your site.
      6 ## Request a Matomo website
      7
      8 First of all, you need to open a ticket for the [Matomo team](https://cern.service-now.com/service-portal?id=functional_element&name=web-infrastructure) requesting a Matomo website for your URL. They will reply to you with the JavaScript snippet that needs to be embedded on your site.
Please register or sign in to reply
### Method 1: Extending JavaScript
Please register or sign in to reply
1. Add to the `mkdocs.yml` file the entry:
```
extra_javascript:
- javascripts/matomo.js
Please register or sign in to reply
```
2. In the `docs/javascripts` folder, create a `matomo.js` file with the JavaScript tracking code that you can find inside the `<script>` tags that the Matomo team replied to you:
    • Suggested change
      18 2. In the `docs/javascripts` folder, create a `matomo.js` file with the JavaScript tracking code that you can find inside the `<script>` tags that the Matomo team replied to you:
      18 2. In the `docs/js` folder, create a `matomo.js` file with the JavaScript tracking code that you can find inside the `<script>` tags that the Matomo team replied to you:
    • Suggested change
      18 2. In the `docs/javascripts` folder, create a `matomo.js` file with the JavaScript tracking code that you can find inside the `<script>` tags that the Matomo team replied to you:
      18 2. In the `docs/javascripts` folder, create a `matomo.js` file with the JavaScript tracking code that you can find inside the `<script>` tags that the Matomo team provided you with:
Please register or sign in to reply
```
var _paq = window._paq = window._paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="https://webanalytics.web.cern.ch/";
_paq.push(['setTrackerUrl', u+'matomo.php']);
_paq.push(['setSiteId', '[cern site id]']);
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);
})();
```
### Method 2: Overrides customization
Once you obtain the JavaScript tracking code, follow [this guide](https://squidfunk.github.io/mkdocs-material/setup/setting-up-site-analytics/#custom-site-analytics) to configure the analytics for your MkDocs site.
Loading