MediaWiki extensions manual
OOjs UI icon advanced.svg
Release status: stable
Implementation Database , Data extraction, MyWiki
Description Provide the page views functionality
Author(s) Mark A. Hershberger (MarkAHershbergertalk)
Latest version 0.3
MediaWiki 1.25+
PHP 5.5+
Database changes Yes
Tables hit_counter
License GNU General Public License 3.0 or later
  • $wgHitcounterUpdateFreq
  • $wgDisableCounters
Translate the HitCounters extension if it is available at translatewiki.net

Check usage and version matrix.

Vagrant role hitcounters
Issues Open tasks · Report a bug

The HitCounters extension provides the page views functionality that was removed in MediaWiki 1.25. HitCounters displays the view count in the page footer and the most viewed pages on a special page called Special:PopularPages.


This extension provides feedback in the form of audience measurement to editors.

Knowing the rough size of one's audience as an editor can provide an incitement benefit for improving more popular articles.

Special:PopularPages encourages editors of a wiki project to focus on improving those articles with the highest traffic, and helps readers discover a project's most curated content.

It also enables determining the wikiFactor, a rough measure of a wiki website's popularity.


New Installation

If you install a new wiki, you don't have to care about old hitcounter numbers.

If you run MediaWiki 1.25 (or newer) you have no visits (hitcounter numbers) yet. Installing HitCounters you will just start counting from zero.

Migration from before MediaWiki 1.25

If you run a MediaWiki version before 1.25 and going to update to 1.26+, you have to prevent loss of your hitcounter numbers.

Wikis using the pageview counter feature in MediaWiki 1.25 (or older) core must be migrated to the extension before updating to 1.26+. Attention: If you do not act according to the following instructions, an update to MediaWiki 1.26 or newer can permanently delete your hitcounter numbers! See task T120216.

If you want to update MediaWiki to version 1.26, currently the following steps have to be done in order to prevent loss of hitcounter numbers:

  1. Use MediaWiki 1.25 and install this extension.
  2. Still in MediaWiki 1.25, run update.php. This step is mandatory! This should migrate the hitcounter data to the new locations:
    • Table hit_counter should exist and should contain all the hit numbers
    • Table hit_counter_extension should exist (and possibly contain information on the few, newest hits)
    • Note that I have not tested if this actually works!
      The SQL files, which are included with the HitCounters extension, demonstrate the SQL commands, which have to be run before(!) running update.php in MediaWiki 1.26, in order to preserve the existing data.
    • Note: HitCounters in Version 0.3 does not work with MediaWiki 1.25. You may try a fork of HitCounters since Version 0.3.2.
  3. After the above steps, update to MediaWiki 1.26 or newer. Running update.php in that version will still remove hitcounter data from the old locations, as far as it is still present there. However, since you have done the migration, the extension should continue working!
  • If using Vagrant , install with vagrant roles enable hitcounters --provision
Manual installation
  • Download and place the file(s) in a directory called HitCounters in your extensions/ folder.
  • Add the following code at the bottom of your LocalSettings.php:
    wfLoadExtension( 'HitCounters' );
  • Run the update script which will automatically create the necessary database tables that this extension needs.
  •   Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.

Differences from core MediaWiki implementationEdit

Before MediaWiki 1.25, the page views counting functionality was in core MediaWiki. This extension is based on that same code, but was deliberately done in a more lightweight way in order to speed up processing time. Many lines of superfluous code were removed. Also, the old MediaWiki core code did numerous database queries on every page hit; these have all been removed as well. This change may possibly lead to some inaccuracies in the data.

The core differences that wiki administrators need to know are:

  • The hit counts are stored in cache.
  • The visible hit count at the bottom of each page is updated only once per day. (Pages with hit count less than 100 are updated once per minute.)
  • If you refresh your browser on a wiki page, that hit is ignored.

What counts as viewEdit

According to tests conducted by several MediaWiki operators, a view is counted if a page is accessed normally (action=view), as well as action=render and when accessing a page revision.

A view is not counted with the other actions, such as action=raw, action=edit, and action=info.


Special page aliases should be created in HitCounters.i18n.magic.php, and magic word aliases in HitCounters.i18n.magic.php.


  • $wgDisableCounters
    When set to true, it disables the notice in the pages footer saying "This page has been accessed 256 times." as well as the special page PopularPages. This configuration parameter was removed with MediaWiki 1.35.0.
  • $wgHitcounterUpdateFreq
    Sets how often page counters should be updated. Default value is 1.
  • $wgEnableCountersAtTheFooter
    This variable is only available in the fork of HitCounters since Version 0.3.3. When set to false, it only disables the notice in the footer of the pages, but NOT the special page PopularPages or the counting functionality itself.


Actual issueEdit

On 7 Dec 2020 was introduced a bug: diff

  1. ObjectCache::getInstance() can not be called without parameter
  2. wfGetMainCache() is correct as shown here

--WikiForMen (talk) 08:22, 23 January 2021 (UTC)

Incompatible extensionsEdit

I need bug reports in Phabricator so that they can be worked on. If you run into a problem with one of the following, please create a phabricator task and link to it here. -- MarkAHershberger(talk) 16:02, 30 July 2016 (UTC)

Fixed issuesEdit

  • This extension previously confused the display of accesses for pages with the same name across namespaces. Resolved by task T163957 for REL 1_31 and above.

Backward compatibilityEdit

Version 0.3.2 of this extensions fork is backward compatible to MediaWiki 1.25. See here.

Version of this extensions fork contains the latest improvements but is only for MediaWiki 1.35+. See here.

See alsoEdit