Modifications and Updates

I can't quite seem to get enough of tweaking my blogger template. I've added the ability to have short summaries for a post followed by a "read more" link. This will let me split up some posts that are too long for the mainpage so you can read them if you are interested in them. I also changed some of my statistics tracking so it'll be easier for me to interpret what my statistics mean. For those interested, read on for what the issue was! I'm using a great little statistics tracking utility called Performancing Metrics. All you have to do is register with them and insert a small piece of javascript code on your blog and it'll quickly track your site.

The default javascript code sets a variable called z_post_title and then calls pmetrics' script with that variable. In this way, it can track how many times people visit each webpage, and because it is their script, they can record some simple stats like what browser my visitors are using and what their screen resolution is. This, by the way, is something everyone can do ... so don't think that I'm doing something that kills your privacy on the internet!

The trouble I was having is two-fold. First, it was hard to tell whether the visitor was either reading my blog on the mainpage or was somehow getting to the individual posts to read. Most of the time, I'm sure, they would be hitting the mainpage, but I wasn't sure how to tell. It would be nice to see if there were any really popular individual post pages for instance.

I solved this pretty easily because blogger allows use of a couple of tags that differentiate whether the page is an individual post page or a main/archive page. These tags look like this: <MainPage>, <ArchivePage> <MainOrArchivePage> and <ItemPage>. So I set z_post_title like so:

<MainPage>z_post_title="[Homepage]<$BlogItemTitle$>";</MainPage> <ArchivePage>z_post_title="<$BlogPageTitle$>";</ArchivePage> <ItemPage>z_post_title="<$BlogItemTitle$>";</ItemPage>

Now when people see my main page, I can tell because the page title will be preceded by [Homepage]. Otherwise, I'll know that its either an archive page (it'll look like March 2006 if that's the page they were looking at) or an item page because it'll just be the title of the post.

The other problem I had was I was getting some odd statistics. In particular, I was getting lots of hits to items that I had posted weeks ago. It turns out that because I was setting z_post_title for every post on the mainpage, it was overriding the variable every time until the last post on the main page! So, the stats weren't making too much sense since I kinda wanted to have an idea how many people were seeing the *first* post on my page.

I fixed that by doing this:

<script> z_post_title=''; </script>

<Blogger> <script> <MainPage>if(z_post_title=='') {z_post_title="[Homepage]<$BlogItemTitle$>}";</MainPage> <ArchivePage>z_post_title="<$BlogPageTitle$>";</ArchivePage> <ItemPage>z_post_title="<$BlogItemTitle$>";</ItemPage> </script> </Blogger> <script id="stats_script" type="text/javascript" src="http://metrics.performancing.com/bl.js"></script>

That's a complete code snippet of what is needed to do the performancing tracking. My thanks to Chris Garret at pmetrics for suggesting the idea. Basically, I initialize the z_post_title to an empty string. Then, if the z_post_title is not set yet, then I set it to the post title. Otherwise, I let it be. At the end of all the posts, z_post_title is still set to the first post of the page! It works as far as I can tell, but I will find out for sure once pmetrics catches up to my changes.

Feel free to use the idea if you have your own blog and want to use pmetrics in a similar way!

Heraldk