Make StatCounter More Readable

我比较爱看这个blog访问的StatCounter统计数据。昨天还比较了一下Google AnalyticsGoStats和StatCounter这几家的统计服务,个人还是觉得StatCounter最好用。Google Analytics界面好难用,GoStats免费用户限制太多。还听说过的比较有名的一个好像叫做MINT。其实这几个都算是比较好的了。昨天还看到了某人主页上用的不知哪家的统计服务,还会弹广告窗口的,lol


StatCounter original pageload list

这条记录上第一行是访问者的ip和域名,第二行是访问的页面的标题,第三行是这次访问的refer地址。比较不爽的一点就是标题和refer地址里面有很多编码之后的中文,我常常还要点一下去看看人家是用什么关键字来查的。研究了一下之后发现标题里面那种%u9AD8这样的编码,后面这四位就是Unicode Number;google搜索的url里面带有的%D0%A1这种是用utf-8编码的,这两个都比较容易用JavaScript来转换。Baidu这个家伙的URL里面看起来和google挺像,也是%CB%C9这样的,但其实用的是GB2312编码,要转换到utf-8需要查很大的表,不是单纯用JavaScript就可以做的了。Whatever,能把标题和google搜索的utf8编码转换过来也就方便不少了。

基本的想法就是在页面读取完之后执行一段JS,这个就需要用到Firefox的插件GreaseMonkey。我按照GreaseMonkey的规范写了一小段User JavaScript,还挺好用,嘿嘿。每次看StatCounter的pageload页面的时候这段小程序就会自动工作,转换以后的效果是这样

StatCounter pageload list after using my script


allLinks = document.evaluate(
for (var i = 0; i < allLinks.snapshotLength; i++) {
    thisLink = allLinks.snapshotItem(i);
    // do something with thisLink
    oldHTML = thisLink.innerHTML;
    //for %uXXXX
    newHTML = oldHTML.replace(
        function (){
            //for utf8 encoding
            newHTML = newHTML.replace(/((%[A-Z0-9][A-Z0-9])+)/g,
                    return decodeURIComponent(p1);
    thisLink.innerHTML = newHTML;

其实Baidu那个也可以使用比较猥琐的方法搞定,先把页面的Encoding手动设成GB2312,然后把鼠标移到baidu那个url上面,浏览器下面的状态栏里面显示的就是汉字了。。可以用Firefox的Content Preference这个插件来锁定StatCounter的编码到GB。

Join the Conversation


Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

  1. OK, good, at least your feedbacks are much better than I got from StatCounter forum. And thank you for telling me the cookie trick.
    I think I’ll keep using GoStats. Good job :P

  2. Here are some details:
    1. Blocking cookie – Yes, within the “my sites” section, click on “edit site profile”, then seek either of the two options: “block count from your PC” or “block IP address”

    2. Titles in the last guests list. Good point, I will include this in the future update. :)
    3. Cities and Visitors on map – I will think of free subsitutes to these features; maybe we will see something similar soon.
    4. Invisible counter: I am thinking about a way to to this economically ;)

    Thanks for your input, I will strongly consider these ideas for future updates.

  3. Thanks, I prefer the English version, it looks neater
    So the functions I want and it seems not provided in free version are
    1. Blocking cookie, so my own clicks won’t be counted
    2. In the “Last guests” list, actually this is my favorite function, I want to see the title of pages on my site, instead of the URL. “Make StatCounter More Readable” makes much more sense than “” in this list.
    3. Cities and Visitors on map are not free…But these two functions are interesting.
    4. Maybe an invisible counter option would fit someone’s taste? However I agree that your site deserve a link from your user.

    Your better points are:
    1. You recognize Chinese
    2. You recognize baidu….the Chinese search engine
    3. Your charts are rich

    Anyway, I can use both yours and StatCounter for some time, though it makes me feel a little messy :)

  4. Actually, the limits for the free GoStats accounts are very liberal. (In fact GoStats retains all historical data trends, most other trackers will not) Maybe there is some questions you have that I can answer to clarify your concerns?

  5. You know what, man?! I’ve just found what why my firefox aren’t showing my flickr photos!! I don’t even know when and how I accidentally blocked flickr photos from viewing… geez~~ I am so glad I finally found it out. It has been bothering me for a loooonnnngggg time!! ^__^ now, I am happy even without StatCounter.. hehe.

  6. I had a look at blogpatrol and its demo service, which showed the visits stat of its own. And I saw your IP there :P

    I guess the way of using StatCounter is almost the same as blogpatrol.
    1 Sign up there
    2 create a project
    3 use “Install Code” to get the codes with styles you want (probably invisible, or like my counter)
    4 add these codes to the template of your blog.

    It’s ok to use both of them together. And you can set the “start on” number of the counter, so maybe you can add your counts from blogpatrol here, hoho