The best location for your website tracker code in Wordpress

by Derek Lim on October 10, 2009

It’s always the same set of instructions -  place this code in the index.htm or index.html between the <body> and </body> tags or to download and install the plugin. It’s not exactly troublesome but I’m looking at a more future-proof option.

<body> Tag

For wordpress this means going to /wp-content/themes/, choose the current theme and insert the code into any php files with a <body> tag. Usually it is the the footer.php. However the problem is that each time we change our theme, we have to remember to insert the code into the new theme php file. Considering that there are so many free WP themes out there, it can be particularly annoying for those who change their theme often.

Most premium themes usually offers lifetime support for their themes so that they can remain compatible with future Wordpress updates. This usually comes with a couple of files that have to be replaced. This poses another problem because if the user forgot that his tracker code is in one of those files, he will lose the tracking function. Who do we blame? Usually the site tracker first.

Plugins

Plugins work great. We don’t have to worry about changing our theme. However, most plugins are usually outdated – they are not able to keep pace with Wordpress. I’m using statcounter and their plugin is compatible up to 2.5.1.  Of course, this doesn’t mean that the plugin won’t work but would you take a chance?

Widgets?

Correct me if I’m wrong, but for self hosted blogs, the text widget is supposed to support javascript ya? I am using statcounter and the code provided to me is in javascript.  It works  but the report seems a little laggy.

It seems like the  simple text widget is the solution I’m looking for. No need to worry about changing themes, plugins and even wordpress updates. I will be monitoring it for another week or so to verify that it is indeed working.

Where else do you think is a good place for your tracker code in wordpress?

{ 2 comments… read them below or add one }

Polprav October 23, 2009 at 3:23 am

Hello from Russia!
Can I quote a post in your blog with the link to you?

Derek Lim October 23, 2009 at 9:46 pm

Hi Polprav,

Sure. Go ahead.

Cheers!

Leave a Comment

Previous post: Don’t Let The Discount Coupon Go To Waste

Next post: Thesis Theme Discount Code