Wiki source code of Statistics

Last modified by superadmin on 2026/11/25 21:35

Show last authors
1 XWiki records page views itself: a listener observes them and a storage thread writes them to the database. Nothing bundled reads that data back. The [[Statistics Application>>doc:extensions:Extension.Statistics Application.WebHome]] is its only interface, and it has neither been bundled nor maintained since XWiki 8.0; its own extension page recommends the [[Matomo Integration>>doc:extensions:Extension.Piwiki Integration.WebHome]] instead, which tracks page views in a Matomo server of your own and ignores every setting on this page.
2
3 So the switches below decide whether XWiki fills its statistics tables, not whether anybody can read them. Three of them decide whether a page view is stored, and one ships turned off.
4
5 == The three switches ==
6
7 * ##xwiki.stats##, in ##xwiki/WEB-INF/xwiki.cfg##, turns the statistics module on or off for the whole instance: the storage thread and the listener. It is on unless you turn it off.
8 * The ##statistics## field of a wiki's ##XWiki.XWikiPreferences## object turns storage on or off for that one wiki, and has to be [[added by hand>>doc:documentation.xs.admin.statistics.enable-statistics-subwiki.WebHome]].
9 * ##xwiki.stats.default## decides for every wiki that has no such field. It is the one statistics line the shipped ##xwiki.cfg## leaves uncommented, and it ships as ##0##, so statistics storage is off on a new instance, whatever the module switch says.
10
11 == Whether a page view is recorded ==
12
13 {{plantuml}}
14 @startuml
15
16 start
17 :A page is viewed;
18 if (is the statistics module enabled?) then (no)
19 :Nothing is recorded at all;
20 stop
21 endif
22 if (does the wiki define a "statistics" field?) then (yes)
23 if (is it set to 1?) then (no)
24 :The view is not stored;
25 stop
26 endif
27 else (no)
28 if (is the default set to 1?) then (no)
29 :The view is not stored;
30 stop
31 endif
32 endif
33 if (is the viewing user filtered out?) then (yes)
34 :The view is not stored;
35 stop
36 endif
37 :The view is stored;
38 stop
39 @enduml
40 {{/plantuml}}
41
42 [[Statistics Parameters>>doc:documentation.xs.admin.statistics.parameters.WebHome]] lists these properties with their defaults, and the two properties that filter out the users whose activity is never counted. In a [[multi-wiki>>doc:documentation.xs.admin.wikis.nested-pages.WebHome]] instance, that is also where the difference between the instance-wide default and a wiki's own field matters most.

Get Connected