Drupal Statistics on Steroids
The statistics collected by Drupal’s builtin statistics module is rather limited and there are no facilities to create nice graphs or in other ways manipulate the collected data. On the other hand there are a lot of great and free web tracker services out there which let you gather statistics on your visitors and then query that data in various ways. Today, I integrated one such service, StatCounter, with the Drupal based web site you are looking at right now.
StatCounter, which I stumbled across today, collects lots of data on your visitors (without sacrificing their privacy, of course). The cool thing about StatCounter which I think sets it apart from the competition is that it is completely free in the sense that it won’t cost you anything yet still you don’t have to add a link to their web site if you don’t want to and no ads will pop up in the face of your visitors. In fact, your visitors will not be able to tell (if you don’t want to and as long they don’t take a look at your site’s HTML code) that they are being tracked.
Integrating StatCounter (and any other similar service) with a Drupal web site is a piece of cake. This is how I did it (in Drupal 4.6.0):
- Create a new block by selecting administer -> blocks in the menu and click the add block tab. You can leave the Block title field empty. Paste the HTML code given to you by the web tracker service in the Body block text area. Make sure the Full HTML radio button is selected in the Input format section. Enter a description in the Block description field (I entered “StatCounter code”) and hit the Save block button.
- The new block will now be listed in the Disabled section in the list of available blocks on the blocks page (administer -> blocks). The description you used for your block will be used as the label in the list. Tick the checkbox in the Enabled column next to the web tracker block we created in 1, change its weight and placement (left or right sidebar) if necessary and hit the Save blocks button.
That’s all there is to it! The HTML code you got from the web tracker service should now be included in all the pages of your site (have a look at the source of your site’s pages to confirm this). If you don’t want it to be used on every page you should click the configure link next to the block we created above. The block configure page shown lets you specify individual pages or content types (blogs, pages, stories, etc) on which the block should be included.