Better Stats Insertion

Better Stats Insertion is a WordPress plugin that allows you to easily insert stats code from trackers such as Google Analytics, SiteMeter, or just about any other. The best part about BSI, though, is that, unlike just putting the code in your templates, BSI will make sure only the pages you want to be tracked are. This means your 404 pages will not be tracked, and neither will page previews when editing.

NOTE: In version 0.1 of BSI, I made a pretty big typo—I gave the wrong instructions as to which tag to put in your template. Please download the newest version below to correct this.

Compatibility

Right now, it’s only been tested with WordPress 2.1, but it should work with older versions as well. If you find a version of WP it doesn’t work with, let me know.

Changelog

  • 0.2 – Fixed typo in instructions—it’s bsi_insert() not bsi_include()…stupid me!
  • 0.1 – Initial release

To-do List

  • Have more control over which pages are tracked (more options)
  • Automatic insertion (no need to edit templates)
  • Allow different options for different trackers.
  • Have a pattern matching system to identify which pages to track and to not track

Anything you want to see in the next release of BSI? Let me know!

Download

You can download version 0.2 of Better Stats Insertion here.

Installation and Usage

To install, just drop better_stats_insertion.php in your wp-content/plugins folder. Then, go to the “Plugins” tab to activate. Edit your tracking code by going to Options -> Better Stats Insertion. Then, in your template, wherever you want the tracking code to appear (most likely your footer or sidebar), insert the following:

<?php if ( function_exists( 'bsi_insert' ) ) { bsi_insert(); } ?>

Everything should now be working!

Find a bug?

Although I would love to think I write perfect code, I don’t, so there are bound to be errors. If you happen to spot one, let me know! Also, if there is anything you’d like to see in future releases, please, give me your thoughts.