Ruwiki pgcounter
There was a special counter for Wikimedia projects which was first installed on Russian Wikipedia (and supported by majority of users there). It tracked hits to pages (this feature exists in MediaWiki but is disabled for Wikipedia due to high servers load). Also, referrers were logged (useful tool to know where new users come from; or to detect anti-Wikipedia flashmobs).
The main counter daemon was on Toolserver (zedler) under account of User:Edward Chernenko (edwardspec). It used u_edwardspec.pub_<LANG>wiki_pgcounter table to log visits (another Toolserver users may read this table from their scripts).
The counter was installed on: Russian Wikipedia, Tamil Wikipedia, Kannada Wikipedia.
I'm sysop; how to install on my wiki?
editFirst you should think about popularity of your wiki. Wikipedias are placed on mighty servers but zedler is server only for some developers. It should not be overloaded. So, this counter currently can handle three types of wikis:
Small wiki
editThat means there're less then 1 hit to page in your wiki per second. Such a wikis can use exact hit counter which counts each hit. The code to enable counter is
var disable_counter = 0; function count_me() { if(!disable_counter && window.location.href.match("^http://<LANG>.wikipedia.org/wiki/") && !window.location.href.substring(7).match(":")) { var img = new Image(); img.src = "http://tools.wikimedia.de:22902/1" + document.referrer; } } addLoadEvent(count_me);
Medium wiki
editThis is wiki with less then 500 hits to pages per second. That's too high load so JS code marks only one hit of ten (selected randomly). The code is
var disable_counter = 0; function count_me() { if(disable_counter != 1 && window.location.href.match("^http://ru.wikipedia.org/wiki/") && !window.location.href.substring(7).match(":")) { var rnd = Math.random() > 0.1 ? 1 : 0; if(rnd == 0 || (document.referrer && !document.referrer.match("(wikipedia.org|wiktionary.org|wikiquote.org|wikisource.org|wikimedia.org|yandex.ru|google.ru|google.com)"))) { var img = new Image(); img.src = "http://tools.wikimedia.de:22902/" + (rnd == 0 ? "1" : "0") + document.referrer; } } } addLoadEvent(count_me);
Big wiki
editThis is for huge wikis only like enwiki (only 1 hit of 500 should result in hit to counter). Replace
var rnd = Math.random() > 0.002 ? 1 : 0;
line in code for medium wikis with
var rnd = Math.random() > 0.002 ? 1 : 0;
Do not overload server
editAdding code for small wiki into English Wikipedia global Monobook.js will be considered as DDOS attack. Please do not do so ;)
Where to include code
editInsert it into MediaWiki:Monobook.js of your wiki. Note that you may require also add addLoadEvent() function to the beginning of this file if it not exists there. Code is below.
function addLoadEvent(func) { if (window.addEventListener) window.addEventListener("load", func, false); else if (window.attachEvent) window.attachEvent("onload", func); }
How to request to enable your new counter
editAfter adding this code you should write to Edward's user talk a request with your language code and wiki type (small/medium/big) and wait at least 2 days (to ensure that browser caches are refreshed anywhere). You will be notified in your wiki when counter will be on.
Privacy
editAny registered user may disable this counter by typing
disable_counter = 1
into their monobook.js.
This option is a condition for consensus on ruwiki but if your users allow it you may remove
if(disable_counter != 1)
braces from global code.
Anyway this counter gathers no personal information except referrers. As referrers logging with full timestamps may not be allowed by Privacy policy, only date is logged.
Tools
edit- TOP100 page
- http://tools.wikimedia.de/~edwardspec/cgi-bin/top100.cgi
- Referrers log
- http://tools.wikimedia.de/~edwardspec/cgi-bin/reflog.cgi
Please append '?uselang=<LANG>" to tool URL in order to get stats for another wiki ('ru' is default value).
Code
editThe counter daemon code is free and distributed under GPL license v.2 or greater. See current code here: http://tools.wikimedia.de/~edwardspec/src/wikicnt_daemon.pl (Perl).
Current successors
edit- WikiStats (raw data)
- Wikipedia article traffic stats (per page)
- THEwikiStics (toplists)