I want to log / track unique page visits to a page in a mediawiki wiki, but I can't ask the this mediawiki admin to give me the data. If this was a page on my website I would just use statcounter.com. But it is a mediawiki wikipage that I contribute to and want to get the statistics.
4 Answers
If you're able to install extensions on the site at all then you could try the one for Google Analytics at http://www.mediawiki.org/wiki/Extension:Google_Analytics_Integration
Otherwise, another solution might be to try a "web beacon". That's where you insert a resource from an external site into a page so you can track the hits for it when pages are requested by a browser. For example, you could add an image to a post with a URL like http://www.yourdomain.com/tracking_pixel.gif then count the requests for it. However, this depends on the setup of MediaWiki because the ability to insert external images into a page might have been disabled. You can read more about that at http://www.mediawiki.org/wiki/Manual:Linked_images
Also note that the requests for the image won't be unique so you will need to attach a cookie to it so you can identify unique users.
Another way is: Go to Special:SpecialPages
of a given wiki, and check if it has Special:PopularPages
; example:
- http://en.wikipedia.org/wiki/Special:SpecialPages - doesn't have it
- http://www.alsa-project.org/main/index.php/Special:SpecialPages - has it
If you have Special:PopularPages
, then you can use that to list page views (counts); but not if it isn't enabled; example:
- http://en.wikipedia.org/wiki/Special:PopularPages - results with
No such special page
You have requested a special page that is not recognized by Wikipedia. A list of all recognized special pages may be found at Special:Specialpages. - http://www.alsa-project.org/main/index.php/Special:PopularPages - results with
Popular pages
Jump to: navigation, search
Showing below up to 50 results starting with #1.
View (previous 50 | next 50) (20 | 50 | 100 | 250 | 500)
Main Page (10,849,812 views)
Download (1,310,228 views)
Documentation (428,914 views)
SoundcardTesting (395,408 views)
...
There isn't any general way to get unique visits in MediaWiki. The closest you can come is to query the API with a query like action=query&prop=info&titles=My+Page
and look for the counter
property in the response, but do note this isn't "unique" visits and it may be disabled on a particular installation (e.g. Wikimedia wikis disable it because it is useless with the heavy caching they do).
Your best bet is to ask the admin for statistics, or ask them to install your statcounter.com web bug or the like.
In MediaWiki 1.25 (.0 stable 2015-05-25) and later, you can re-add the functionality with Extension:HitCounters. It does less, keeping counters in a cache and not issuing multiple updates to the database on each hit, but it should implement much of the functionality, accessible as addressed in saadu's answer to this question.