Integration manual


  1. Matomo follow-up
    1. Version 2.9 and higher
    2. Version 2.7 and 2.8
    3. Version 2.6 and lower
  2. Advanced settings: statistics on searched keywords
  3. Displaying Matomo statistics

Matomo follow-up

Version 2.9 and higher

1. Import the following XSL :

<xsl:import href="gdpr:matomo"/>

2. Dans la section "<head>" de vos chartes, faire appel au template "matomo"

<html>
   <head>
       [...]
       <xsl:call-template name="matomo"/>
   </head> 
   <body>
       [...]
   </body>
</html>

Version 2.7 and 2.8

1. Import the following XSL :

<xsl:import href="gdpr:piwik"/>

2. Dans la section "<head>" de vos chartes, faire appel au template "piwik"

<html>
   <head>
       [...]
     <xsl:call-template name="piwik"/>
   </head> 
   <body>
       [...]
   </body>
</html>

Version 2.6 and lower

1. Import the following XSL :

<xsl:import href="plugin:web-analytics://stylesheets/piwik.xsl"/>

2. Dans la section "<head>" de vos chartes, faire appel au template "piwik"

<html>
   <head>
       [...]
     <xsl:call-template name="piwik"/>
   </head> 
   <body>
       [...]
   </body>
</html>

Advanced settings: statistics on searched keywords

Keyword statistics is not compatible with the use of the cookie manager tarteaucitron

Matomo provides statistics on the most searched keywords.

By default Ametys sends the Matomo server the keywords searched for via the "texfield" search field.

If you need to track one or more other search fields, use the "matomo" template (or "piwik" depending on the version of your plugin web-analytics), specifying the name(s) of the search fields to be tracked as in the example below:

<xsl:call-template name="matomo"> 
   <xsl:with-param name="keywordFields"> 
     <fields> 
        <field name="textfield"/> 
        <field name="fulltext"/> 
        <field name="keywords"/> 
     </fields> 
   </xsl:with-param> 
</xsl:call-template> 

Displaying Matomo statistics

From version 2.9.0

From version 2.9.0 onwards, Matomo statistics on the number of views can be retrieved and displayed.

Pour cela vous devrez importer le JS suivant dans la section <head> de votre charte graphique:

<script src="{ametys:pluginResourceURL('web-analytics', 'js/AmetysMatomoHelper.js')}" type="text/javascript"/>

This file provides a JS helper AmetysMatomoHelper.getPageData to retrieve statistics on the number of views of the current page.
The arguments are as follows:

  • selector : jquery selector to identify the HTML element that will display the statistics
  • contextPath: the path to the current context
  • pageUrl: url absolute value of the page for which you wish to obtain statistics. Leave empty or null for current page
  • callback: JS function to be called after statistics retrieval (optional)

The helper retrieves the statistics from the Matomo server and modifies the target HTML elements identified by a "data-matomo" attribute as follows:

  • data-matomo="nb-visits": total number of views
  • data-matomo="nb-visits-last-days": number of views over the last X days, where X is defined in the site parameters
  • data-matomo="last-days": range of the last X days

Example of integration:

<div class="stats" style="display: none">
   <span data-matomo="nb-visits" ></span> vues dont <span data-matomo="nb-visits-last-days"></span> les <span data-matomo="last-days"></span> derniers jours
</div>
<script type="text/javascript">
   $j(document).ready(function() {
     AmetysMatomoHelper.getPageData(".stats", "<xsl:value-of select="$site-uri-prefix" />", null, function() {
        $j(".stats").show();
    });
   });
</script>
Back to top

Web analytics