Last edited 16 hours ago
by Redaktion

HitCounters


The extension HitCounter counts human page views.

How it works

The extension counts page views and stores them in the MediaWiki database field page.page_counter. Other extensions use this field to return page visit numbers.

Output of the page views number

The extensions Semantic MediaWiki (SMW) and DPL3 (DPL), which are bundled with the BlueSpice distribution, both use the field value for page.page_counter. However, the number that is returned in SMW and DPL queries usually differs.

Why SMW and DPL show different page-view numbers

Even when both rely on HitCounters, they read the values at different points in time and with different caching layers, which leads to discrepancies. Below are the main reasons.

Feature Source Updates May lag?
SMW Number_of_page_views SMW store (snapshot) Only when page is parsed/resaved ✔ Yes
DPL ordermethod=counter page.page_counter (live) Immediately when HitCounters logs a view ✘ No

SMW stores values (snapshot) – DPL reads live values

SMW’s property "Number_of_page_views":

  • SMW stores the value in its DataStore.
  • A page must be parsed/resaved for SMW to update the stored property.
  • Therefore: the number can lag behind the real counter.


DPL3 ordermethod=counter:

  • DPL reads the current page.page_counter field directly.
  • It does not use SMW data.
  • This always shows the latest number, as recorded by HitCounters.


Result: SMW can show an older number than DPL.

Caching differences (ParserCache vs. SMW store)

SMW:

  • Uses its own store (SQL + SMW query cache).
  • Property values only change when the page is reparsed.


DPL:

  • Uses MediaWiki’s normal page cache but reads the counter directly every time.


If a page received new hits since its last SMW update:

  • DPL shows the new higher number
  • SMW still shows the older value until the page is updated

HitCounters updates only on full page views

HitCounters increments the view count only when:

  • A normal, human page view occurs
  • Not on: API calls, bot views, thumbnail loads, SMW queries, DPL queries

This means numbers may diverge temporarily depending on viewing patterns.

Some skins bypass counters

If some users view pages via:

  • mobile skin
  • VisualEditor previews
  • REST requests
  • API-parsed pages

…those views may not be counted.

If these users access a page differently at different times, SMW and DPL appear inconsistent.

SMW’s “Number_of_page_views” rounds or normalizes values

SMW’s special property sometimes:

  • stores the view count as an integer
  • may update only when semantic parsing occurs
  • may skip updates depending on SMW’s DeferredUpdate behavior

DPL always shows the raw integer.

Quick way to test

Take a page with a visible difference (example: SMW shows 120, DPL shows 132).

Do this:

  1. Open the page → Edit → Save (no change needed). This forces SMW to refresh Number_of_page_views.
  2. Run your SMW query again.

You will see SMW “catch up” to the DPL counter. However, the values might still differ based on the above reasons.


Example queries:

'''Output SMW:'''
{{#ask: [[:+]] [[Modification date::+]]
|?Number_of_page_views
|limit=5
|format=ul
|headers=hide
|sort=Number_of_page_views
|order=desc
|searchlabel=
}}

'''Output DPL:'''
<dpl>
namespace = 
ordermethod = counter
order = descending
count = 5
addpagecounter = true
</dpl>

Output SMW:

Output DPL:



PDF exclude - start

To submit feedback about this documentation, visit our community forum.

PDF exclude - end