Adding statcounter to WordPress

I’m thinking about using the free statcounter service on my site, but it requires that I add a little bit of javascript to each page. If I was running a single theme, I could probably find all the appropriate </body> tags and just paste in the statcounter code. But I’m trying to support multiple themes; besides, where’s the fun in cutting and pasting a bunch of code? Also, what if I need to change the statcounter code for some reason? So I think the Right Thing to do here is come up with a plugin for the wp_footer action which will insert some user-specified code, (in this case, my statcounter javascript). I haven’t found a plugin for statcounter, so I’ll be searching for a generic footer plugin. If I can’t find anything, I guess I’ll have to roll my own.

About Jim Vanderveen

I'm a bit of a Renaissance man, with far too many hobbies for my free time! But more important than any hobby is my family. My proudest accomplishment has been raising some great kids! And somehow convincing my wife to put up with me since 1988. ;)
This entry was posted in Uncategorized and tagged , , , . Bookmark the permalink.

6 Responses to Adding statcounter to WordPress

  1. Bitcloud says:

    Yeah I’m on a similar problem here myself. Let me know if you have any luck huh?

  2. jim says:

    Sorry, Bitcloud–I haven’t found anything yet, so it looks like it’s time for me to learn how to write plugins. This could get ugly…

  3. jim says:

    I have a rudimentary plugin for this. See the comments on this article.

  4. Pingback: SonicChicken weblog » Blog Archive » Footer plugin requirements, notes

  5. Pingback: SonicChicken weblog » Blog Archive » Statcounter on my WordPress blog

Leave a Reply

Your email address will not be published. Required fields are marked *