Wiki source code of Matomo for better statistics
Last modified by Patrik Mattsson on 2020/03/22 15:06
Show last authors
| author | version | line-number | content |
|---|---|---|---|
| 1 | {{box cssClass="floatinginfobox" title="**Contents**"}} | ||
| 2 | {{toc/}} | ||
| 3 | {{/box}} | ||
| 4 | |||
| 5 | = Introduction = | ||
| 6 | |||
| 7 | To get more in-depth statistics about the usage of your XWiki-installation, the recommendation is to use [[Matomo>>https://matomo.org/]]. | ||
| 8 | This article will go through the settings necessary for the [[extension>>https://extensions.xwiki.org/xwiki/bin/view/Extension/Piwiki%20Integration]] and inside of [[Matomo>>https://matomo.org/]] to get the best possible experience. | ||
| 9 | |||
| 10 | This article will also show how to configure [[Matomo>>https://matomo.org/]] to aid in motivating users for a internal wiki to contribute to the article using [[gamification>>Drafts.Matomo for better statistics.WebHome||anchor="HGamification-Motivateyourusers"]] ([[for more info about the term, click here>>https://en.wikipedia.org/wiki/Gamification]]) | ||
| 11 | |||
| 12 | It is my goal to extend this article with how to communicate with the [[Matomo's Analytics API>>https://matomo.org/docs/analytics-api/]] to show statistics directly in XWiki with Velocity-scripts, but that will come later. | ||
| 13 | |||
| 14 | //Note: The regular expressions used for matching the different actions **should** support main-wikis and both types of sub-wikis.// | ||
| 15 | |||
| 16 | ---- | ||
| 17 | |||
| 18 | == [[Matomo>>https://matomo.org/]] == | ||
| 19 | |||
| 20 | === Administration - Privacy - Users opt-out === | ||
| 21 | |||
| 22 | 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. | ||
| 23 | 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. | ||
| 24 | |||
| 25 | === Administration - Websites - Manage === | ||
| 26 | |||
| 27 | 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>>http://HOSTNAME/bin/view/Matomo/#HPrivacy]] | ||
| 28 | If it is set to **No (Default)**, it will remove **{{{#HPrivacy}}}** from the logs. | ||
| 29 | |||
| 30 | To log what users are searching for, you need to: | ||
| 31 | |||
| 32 | * Set **Site Search** to **Site Search tracking enabled** | ||
| 33 | * Disable **Use default Site Search parameters** by pressing on the green arrow to the left of the option | ||
| 34 | * Set **Query Parameter** to **text** | ||
| 35 | * **Categories** in [[Matomo>>https://matomo.org/]] 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. | ||
| 36 | |||
| 37 | 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** | ||
| 38 | |||
| 39 | What **Currency** is set to isn't relevant for a internal wiki. | ||
| 40 | You should set **Time zone** to the same time zone as the servers configuration to simplify future troubleshooting. | ||
| 41 | |||
| 42 | == Administration - Websites - Goals == | ||
| 43 | |||
| 44 | Using **Goals** in [[Matomo>>https://matomo.org/]] will make it easy to track how your XWiki is being used. | ||
| 45 | It is also a requirement if you want to use [[gamification>>Drafts.Matomo for better statistics.WebHome||anchor="HGamification-Motivateyourusers"]]. | ||
| 46 | |||
| 47 | 1. Press **ADD A NEW GOAL** | ||
| 48 | 1. Name the goal based on the action (keep it short, **View, Edit, Create, Delete** and **Login** are good alternatives) | ||
| 49 | 1. If you want to, fill in **Description** to ensure that everyone understands the reason for the goal | ||
| 50 | 1. Set **Goal is triggered** to **when visitors** and **Visit a given URL (page or group of pages)** | ||
| 51 | 1. Set **where the URL** to **matches the expression** and copy the corresponding **regular expression** from the box below this list | ||
| 52 | 1. ((( | ||
| 53 | Set **Allow multiple conversions per visit** to: | ||
| 54 | |||
| 55 | (% style="width:50%" %) | ||
| 56 | |**View, Edit, Create**, **Delete** and **Admin**|**Allow Goal to be converted more than once per visit**) | ||
| 57 | |**Login** |**(default) Goal can only be converted once per visit** | ||
| 58 | ))) | ||
| 59 | |||
| 60 | **Regular Expression for Goals** | ||
| 61 | {{code language="perl"}}\/(bin|wiki\/.*?)\/(view|viewrev)\/ | ||
| 62 | \/(bin|wiki\/.*?)\/(edit|inline)\/ | ||
| 63 | \/(bin|wiki\/.*?)\/create\/ | ||
| 64 | \/(bin|wiki\/.*?)\/delete\/ | ||
| 65 | \/(bin|wiki\/.*?)\/login\/ | ||
| 66 | \/(bin|wiki\/.*?)\/admin\/{{/code}} | ||
| 67 | |||
| 68 | ---- | ||
| 69 | |||
| 70 | == XWiki == | ||
| 71 | |||
| 72 | To get this up and running, we will first have to install the Matomo integration using the extension manager. | ||
| 73 | |||
| 74 | === [[Matomo Application>>https://extensions.xwiki.org/xwiki/bin/view/Extension/Piwiki%20Integration]] === | ||
| 75 | |||
| 76 | When you've installed [[Matomo Application>>https://extensions.xwiki.org/xwiki/bin/view/Extension/Piwiki%20Integration]], you need to configure it. | ||
| 77 | Go to **Administer Wiki - Other - Piwik //(old name for Matomo)//**. | ||
| 78 | |||
| 79 | * **PIWIK URL** - enter the URL to your Matomo-installation | ||
| 80 | * **TRACKING METHOD** - Choose Javascript Tracking | ||
| 81 | * **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**)// | ||
| 82 | * **USER TRACKING** - Set this to **Yes** if you want to know what each user is doing //(requirement for **gamification**)// | ||
| 83 | * **MULTIDOMAIN TRACKING** - If you have sub-wikis with different hostnames and want to track them properly, set this to yes | ||
| 84 | * **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) | ||
| 85 | |||
| 86 | === XWiki - Getting data from [[Matomo API>>https://developer.matomo.org/api-reference/api-reference-introduction]] === | ||
| 87 | |||
| 88 | ==== URLs ==== | ||
| 89 | |||
| 90 | ==== Velocity ==== | ||
| 91 | |||
| 92 | {{code language="velocity"}} | ||
| 93 | {{velocity}} | ||
| 94 | ############# | ||
| 95 | ##Variables## | ||
| 96 | ############# | ||
| 97 | #set( $token = "anonymous") | ||
| 98 | #set( $tokenAuth = "&token_auth=$token") | ||
| 99 | #set( $baseURL = "http://URLTOMATOMOINSTANCE/index.php" ) | ||
| 100 | #set( $module = "?module=API&method=UserCountry.getCountry" ) | ||
| 101 | #set( $siteAndPeriod = "&idSite=1&period=month&date=today" ) | ||
| 102 | #set( $formatAndFilter = "&format=JSON&filter_limit=10" ) | ||
| 103 | #set( $url = "$baseURL$module$siteAndPeriod$formatAndFilter$tokenAuth" ) | ||
| 104 | |||
| 105 | $xwiki.getURLContent($url) | ||
| 106 | {{/velocity}} | ||
| 107 | {{/code}} | ||
| 108 | |||
| 109 | ---- | ||
| 110 | |||
| 111 | == Gamification - Motivate your users == | ||
| 112 | |||
| 113 | When running XWiki for internal use, you can use **Goal Revenue** as a way to motivate your users to create and update content. | ||
| 114 | In other words, use **gamification **to motivate your users to improve the wiki. | ||
| 115 | Goals have a monetary value since Matomo was designed for webshops. In this scenario, that value is the **score **. | ||
| 116 | |||
| 117 | When creating your goals, give **Create **the highest score, **Edit **as second highest and **View **the lowest score. | ||
| 118 | Users score higher for creating new material or ensuring existing material is current. | ||
| 119 | **Delete**, **Login **and **Admin** are unlikely to improve content and will not have a score. | ||
| 120 | |||
| 121 | Below is an example of what score to give the different actions: | ||
| 122 | |||
| 123 | (% border="3" style="width:10px" %) | ||
| 124 | |=Create|10 | ||
| 125 | |=Edit|5 | ||
| 126 | |=View|1 | ||
| 127 | |||
| 128 | Setup a weekly email-report or make the statistics available for everyone who you want to motivate. |