diff --git a/docs/advanced/matomo.md b/docs/advanced/matomo.md new file mode 100644 index 0000000000000000000000000000000000000000..40bf8ad43f0fa3249ded18f852dcf95daa61231e --- /dev/null +++ b/docs/advanced/matomo.md @@ -0,0 +1,35 @@ +# Site analytics - Matomo registration + +In order to track your site using Matomo web analytics you need to follow these steps. + + +## 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. + +### Method 1: Extending JavaScript + +1. Add to the `mkdocs.yml` file the entry: + + ``` + extra_javascript: + - javascripts/matomo.js + ``` + +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: + + ``` + 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. diff --git a/mkdocs.yml b/mkdocs.yml index 574ca9e0c8ab4e1259ae0a5bec25c55f4b18f5a4..88c2db470449bc50fb69cea42e0780365ff97aa1 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -49,4 +49,5 @@ nav: - 'Install packages': advanced/install_packages.md - 'Custom domains': advanced/custom_domains.md - 'Technical Network visibility': advanced/technical-network-visibility.md + - 'Site analytics with Matomo': advanced/matomo.md - 'FAQ': faq.md