MT Dynamic and Shaun Inman’s Shortstat

in Movable Type, Sites, Webdev

For my website statistics, I use the amazing Shortstat by Shaun Inman. It gives me a detailed information. I can see the referers, number of visitors, etc. If you need statistics for your website, you should give it a try. Recommended.

Before having dynamic publishing for this site, I got no problem at all with the statistics. But, not after that. The default line to call the script does not work in the dynamic publishing.

Shorstat in MT static publishing

As the manual mentioned, to track the pages, I only need to include this single line:

<?php @include_once($_SERVER["DOCUMENT_ROOT"]."/shortstat/inc.stats.php"); ?>

in in pages needed to be tracked — you need to point the inc.stats.php correctly. In all my templates (Main Index, Archives Template), everything is OK in the static publishing.

Shorstat in MT dynamic publishing

But of course, non-MT user also uses this stats. And there are some methods about making this shortstat work nicely. Yes, from that page, from MT user, it is noted that: “No rules, just throw the ShortStat include anywhere.” I think “No rules, just throw the ShortStat include anywhere if you’re using the static publishing/having the static file(s).”

If I use the regular line included in my dynamic template, I got this kind of error:

mysql_pconnect(): Access denied for user: 'myusername@localhost' (Using password: NO)

Well, let’s make it fast. This is what I did enable the Shortstat in my MT dynamic publishing.

First, install the Shortstat in your site. ;)

Edit the Dynamic Site Bootstrapper template which produces the mtview.php file. Originally — if you haven’t touch this template — you will have this:

<?php
include('<$MTCGIServerPath$>/php/mt.php');
$mt = new MT(<$MTBlogID$>, '<$MTCGIServerPath$>/mt.cfg');
$mt->view();
?>

Modify that template, add this line: include('/path/to/your/inc.stats.php');. So, your new template file will be something like this:

<?php
include('<$MTCGIServerPath$>/php/mt.php');
include('/path/to/your/inc.stats.php');
$mt = new MT(<$MTBlogID$>, '<$MTCGIServerPath$>/mt.cfg');
$mt->view();
?>

Edit the path to where your inc.stats.php resides. Save the template, and do not forget to republish it. mtview.php is in static publishing. The file is really there.

What’s next? Enjoy it. The statistics will track all your pages from the dynamic publishing, only the dynamic. Once again, if you want to track other pages, use the regular method. Last but not least, great tool Mr. Shaun Inman! Thanks!

If you're new here, you may want to subscribe to my RSS feed go get the latest entry from your RSS reader. You can also have my contents delivered to your inbox.

This entry receives 7 comments.

  1. echa

    pengen coba, tp hanya buat MT ?

    Jun 4, 2005 at 4:45 pm

  2. Thomas

    Apanya Echa? Shortstat-nya itu? Kayaknya bisa untuk semua page asalnya support PHP dan MySQL. WordPress bisa kok, Lala pakai juga itu Shortstat-nya Shaun Inman.

    Jun 4, 2005 at 5:04 pm

  3. echa

    ah pengen coba pake ah :D

    btw itu dibawah comment jaraknya sama commentbox nya kok jauh bgt ya di firefox? :O

    Jun 5, 2005 at 7:13 am

  4. thalia

    ow, kebetulan lagi nyari stats yang simple. cobain ah. thanks ya!

    Jun 6, 2005 at 3:55 pm

  5. echa

    mas, barusan install. IP nya gak dikasih tau ya di shortstat? :D

    Jun 6, 2005 at 10:14 pm

  6. Jauhari

    #3

    Karena begini… Sebabnya begitu ;)

    Jun 9, 2005 at 2:03 pm

  7. santent

    the amazing Shaun Inman, kok bisa sampai gitu ya

    Jun 10, 2005 at 8:47 am