Matomo for better statistics
Introduction
To get more in-depth statistics about the usage of your XWiki-installation, the recommendation is to use Matomo.
This article will go through the settings necessary for the extension and inside of Matomo to get the best possible experience.
This article will also show how to configure Matomo to aid in motivating users for a internal wiki to contribute to the article using gamification (for more info about the term, click here)
It is my goal to extend this article with how to communicate with the Matomo's Analytics API to show statistics directly in XWiki with Velocity-scripts, but that will come later.
Note: The regular expressions used for matching the different actions should support main-wikis and both types of sub-wikis.
Matomo
Administration - Privacy - Users opt-out
If this is a internal wiki, you might want to Disable Do Not Track support (not recommended), but make sure that you aren't breaking any laws or internal policies before doing so.
If this setting is left at the default value, you might not get any statistics if all your users have configured their browsers to send a Do Not Track signal to all webpages.
Administration - Websites - Manage
Enable Keep Page URL fragments when tracking Page URLs to log usage of links with anchors to specific parts of a page, for example: http://HOSTNAME/bin/view/Matomo/#HPrivacy
If it is set to No (Default), it will remove #HPrivacy from the logs.
To log what users are searching for, you need to:
- Set Site Search to Site Search tracking enabled
- Disable Use default Site Search parameters by pressing on the green arrow to the left of the option
- Set Query Parameter to text
- Categories in Matomo can only report the first category identified per search. But if you want to capture searches based on specific meta-data, you can add them in this field.
Here are some of the available search-categories for XWiki: f_type , f_space_facet , f_locale , f_date , f_creator , f_creationdate , f_author , f_attsize , f_attdate , f_mimetype
What Currency is set to isn't relevant for a internal wiki.
You should set Time zone to the same time zone as the servers configuration to simplify future troubleshooting.
Administration - Websites - Goals
Using Goals in Matomo will make it easy to track how your XWiki is being used.
It is also a requirement if you want to use gamification.
- Press ADD A NEW GOAL
- Name the goal based on the action (keep it short, View, Edit, Create, Delete and Login are good alternatives)
- If you want to, fill in Description to ensure that everyone understands the reason for the goal
- Set Goal is triggered to when visitors and Visit a given URL (page or group of pages)
- Set where the URL to matches the expression and copy the corresponding regular expression from the box below this list
Set Allow multiple conversions per visit to:
View, Edit, Create, Delete and Admin Allow Goal to be converted more than once per visit) Login (default) Goal can only be converted once per visit
Regular Expression for Goals\/(bin|wiki\/.*?)\/(view|viewrev)\/
\/(bin|wiki\/.*?)\/(edit|inline)\/
\/(bin|wiki\/.*?)\/create\/
\/(bin|wiki\/.*?)\/delete\/
\/(bin|wiki\/.*?)\/login\/
\/(bin|wiki\/.*?)\/admin\/
XWiki
To get this up and running, we will first have to install the Matomo integration using the extension manager.
Matomo Application
When you've installed Matomo Application, you need to configure it.
Go to Administer Wiki - Other - Piwik (old name for Matomo).
- PIWIK URL - enter the URL to your Matomo-installation
- TRACKING METHOD - Choose Javascript Tracking
- SITE ID - When you created your website in Matomo, it was given a ID that you need to enter here (visible in Matomo - Administration - Websites - Manage)
- USER TRACKING - Set this to Yes if you want to know what each user is doing (requirement for gamification)
- MULTIDOMAIN TRACKING - If you have sub-wikis with different hostnames and want to track them properly, set this to yes
- DOMAIN URL - If you're using MULTIDOMAIN TRACKING, you'll need to enter the main domainname (i.e, if you're subwikis are a.domain.tld and b.domain.tld, you need to enter domain.tld here)
XWiki - Getting data from Matomo API
URLs
Velocity
{{velocity}}
#############
##Variables##
#############
#set( $token = "anonymous")
#set( $tokenAuth = "&token_auth=$token")
#set( $baseURL = "http://URLTOMATOMOINSTANCE/index.php" )
#set( $module = "?module=API&method=UserCountry.getCountry" )
#set( $siteAndPeriod = "&idSite=1&period=month&date=today" )
#set( $formatAndFilter = "&format=JSON&filter_limit=10" )
#set( $url = "$baseURL$module$siteAndPeriod$formatAndFilter$tokenAuth" )
$xwiki.getURLContent($url)
{{/velocity}}Gamification - Motivate your users
When running XWiki for internal use, you can use Goal Revenue as a way to motivate your users to create and update content.
In other words, use gamification to motivate your users to improve the wiki.
Goals have a monetary value since Matomo was designed for webshops. In this scenario, that value is the score .
When creating your goals, give Create the highest score, Edit as second highest and View the lowest score.
Users score higher for creating new material or ensuring existing material is current.
Delete, Login and Admin are unlikely to improve content and will not have a score.
Below is an example of what score to give the different actions:
| Create | 10 |
|---|---|
| Edit | 5 |
| View | 1 |
Setup a weekly email-report or make the statistics available for everyone who you want to motivate.