Forum:Stats Counter Implementation

Hello, I'd like to implement a stats counter on my wiki, I saw on Runescape wiki that they implemented it in the sidebar. I can do that copying their code, but I'd like also to implement the counter, which is an html/js script code, in the home page (simply add the code doesn't work) otherwise it will be ignored in the stats. So i need a simple javascript code which add the code to the page, or even better add the code in a certain position (indicated, for example by an element with a certain class like div class="counter"). Alternately a script which will add the code to the header or the footer (like those clocks scripts).


 * You need to get the code from Quantcast and use that. You can move it around with CSS once it works.

I'm using Histats, what is Quantcast? Also, I forgot to mention that it's suggested to put the code in tags, (in the body of the page) so if I add the body tags to the code will cause problems? Or I don't even have to do that?

Hi, I think I understand what you're asking. To put the counter on the homepage, add your HTML and JS code to a new page in the MediaWiki namespace: the name doesn't matter, maybe try MediaWiki:Counter. Then, at the bottom of your homepage, put Counter. I think you could put that anywhere on the page, although I'm not sure how you would put that in a certain position: I assume you could add the CSS to MediaWiki:Counter and it would stylize it. Cook Me Plox 20:22, August 5, 2011 (UTC)

Thank you, the "verbatin" code works for the main page, but the code I copied from Runescape wiki doesn't work, maybe there is some kind of conflict with the counter code. The original code was here and produce something like this (under the number of pages). My code is this one and the counter code is:

document.write(unescape("%3Cscript src=%27http://s10.histats.com/js15.js%27 type=%27text/javascript%27%3E%3C/script%3E"));  try {Histats.start(1,1597101,4,28,115,60,"00011111"); Histats.track_hits;} catch(err){};  

Did I made a mistake somewhere? (note that even the "code highlight" doesn't recognize the language)
 * Assuming you changed it correctly, because Runescape's code is for sitemeter and you're not using sitemeter, the only thing you need to change is you should use single quotes for  because the double quotes are breaking the whole thing.

The double quotes were the source of the problem, but now it seems the histats counter code is not supported (maybe those script tags aren't supported), the verbatin solution works for the main page, but it doesn't if I use it in that code. So is there a simpler way to add that code on the sidebar? Or another way to "transclude" it in that cell?


 * I see you have it commented out now, which is bad - you never quite got the script right; this revision would be correct if you deleted the line break after the start comment in the Oasis string. With that, it should work, and you can further modify it to display where you want it to.

I put the whole thing in a comment to resume the work later, now for the code, it seems the line breaks are the problem, but if I remove the line breaks between try {Histats.start(1,1597101,4,28,115,60,'00011111'); Histats.track_hits;} catch(err){}; it will cause an error and the page will not load anymore (but not remove them will cause the script to not load). I can use a version which doesn't use a java script, but I wish to know if I can do something about it. If there is another way to add that code to the sidebar, I can use an "invisible" counter too, if it won't conflict with the java script of the counter. I know, I am a bit spoiled : )