jump to navigation

WordPress – StatCounter Plugin April 17, 2006

Posted by Lucanos in : php,programming,wordpress , trackback

I developed this (my first WordPress plugin) based extensively on the works of Ronald Heft, Jr. and his terrific WordPress Plugin “Google Analyticator“.

I learnt a fair bit whilst adapting his plugin to the StatCounter tracking system, and I am sure that any further developments on my part will surely incorporate some of teh terrific ideas used by Ronald in his plugin. No point re-inventing the wheel, after all…

Instructions:

  1. Click HERE for a zipped version of the file.
  2. Unzip this file and upload the enclosed PHP file into your “wp-content/plugins” folder.
  3. Go to your Plugin screen in your WordPress admin console.
  4. Fill out the details, as per the instructions.
  5. Switch the plugin over to Enabled.
  6. Watch your StatCounter counters start ticking over.
  7. Enjoy!

Any suggestions, feedback, ideas, complaints, virgin offerings are more than welcome.

Comments»

1. cavemonkey50 - April 19, 2006

Nice work. A perfect adaptation of my code to meet another stat service’s requirements. While I won’t use it, I hope others will find your new plugin useful.

// Lucanos:

Thank you for your kind words, and for contributing the initial plugin to the community. I really learnt alot taking apart the code and adapting it to a similar situation.

Personally, I am running both your Google Analyiticator and my StatCounter plugins side by side (as there are different features in each which I appreciate). Plus I only believe in selling (or giving away) something I have/am/will use myself.

Once again, thank you for taking the time to look at the code and commenting.

2. Every Flavour Beans » Why I Moved My Blog From Wordpress.com - May 1, 2006

[...] The final task was to create a styling for the programming language code and the shell commands: the first of these tasks was made simpler by the excellent plugin called iG:Syntax Hiliter and I had to add a new style manually to make shell commands standout. Installation of StatCounter and Google Analytics code was made simpler by the plugins created for the same purpose. I am yet to decide whether or not I need the WP-Cache plugin and also something to manage the uploaded images and other such files. Filed under: General — tabrez @ 6:45 am | [Digg this] [del.icio.us] [...]

3. Hunter Chorey - May 17, 2006

I’m having one issue with the plugin – even after filling in the correct IDs, when I choose “Stat Counter Logging is: ENABLED” from the drop-down box and I press update, it continues to say that the plugin is “DISABLED.” I know I’ve filled the IDs out correctly (yes, even removing the quotes from the security variable). Any ideas what might be up?

// Lucanos:

Emailed Hunter.
This problem was solved by Uninstalling and Reinstalling the plugin.

4. laine - May 24, 2006

having the same difficulty as hunter.

i added the statcounter code into the footer.php, it works with no problems but if i switch themes i have to do this each time. hoping your plugin will take care of this for me.

thanks in advance for any help!

// Laine:

laine issue’s was simply brain fade on her part…

nice work luke! thanks!

5. joiz - June 8, 2006

finally! my site is w3c compliant! and the statscounter still works! Nice work Lucanos >>claps hand

// Lucanos:

Happy to hear that you enjoy the plugin.

6. Alan Edwardes - June 12, 2006

Amazing plugin! I spent a whole afternoon trying to make the origional statcounter code w3c compliant, but, after descovering it was impossible, I had to give up. This plugin is the best wordpress statcouter plugin ive ever seen!

7. dirkhaim - June 15, 2006

On some themes your plugin puts in the statcounter code twice, causing double logging. One example of such theme is Hemmed, which you can see on my site. The problem, I believe, rises when you have php embedded into another, like the livesearch.php page of Hemmed. This is going to be quite common as live search options are getting more common.

Any chance you could fix it?

Thanks.

\\ Lucanos:

Thanks for your comment dirkhaim, and for letting me know about a potential bug with this plugin.

Of course, using a real email address in your comment (rather than me@me.com) might have made it easier for me to contact you and discuss what is happening and possible reasons why. And, it’s only with that information that I would be able to even start to try and modify the plugin so that it works properly.

This plugin uses the standard WordPress invokation to be applied as the head section of the HTML for the page is created. If there are other plugins out there which are invoking this plugin (and any other which uses the same trigger – being nearly all of the statistic packages) then maybe you are better off contacting the creator of these livesearch plugins to see if they can modify their code so as not to send this trigger out.

A little effort on your part would make me alot more open to making an effort on my part to modify a plugin which already has a few hundred satisfied customers, a few of which have commented above.

8. posix - June 18, 2006

okay, this will be stupid…
how do i make the counter show up?
i did everything it said on the options page of the plugin and it worked well.
but on my site i’m not seeing a counter anywhere.
don’t you usually need to assign it to the sidebar, footer or wherever you want it?
where’s the code for that?
i’m kinda confused, as you can see.

and to think that this is one of the more noob-friendly plugins …

// Lucanos:

This plugin inserts the required javascript coding into the WordPress pages so that Statcounter can track the visits, but it does not create a user-viewable counter. That is to say – there is no “12345 Visitors” banner shown on pages using this plugin.
If you want to include a counter which your users can see, at the moment you’ll have to use the standard Statcounter code and insert it yourself, manually, into the templates for your site.
At a later stage, I may look into adapting this plugin to allow you to include a user-viewable counter, but at the moment, as an invisible counter, it seems to be doing well…
9. Iman - June 20, 2006

I’m a little confused
after I enabled the plugin should i also add the js code to my page or not?

// Lucanos:

No – You don’t need to do anything else to have your site statistics tracked by StatCounter. There will be no user-viewable counter or indicator on the pages, but the JS code and everything else is automatically generated and inserted into the page by the plugin.
So if you have enabled the plugin, and provided all the relevant details in the setup page, then your stats should start appearing in StatCounter immeadiately.
10. Dean - July 2, 2006

Is there a way to view stats from within my site, versus going to StatCounter’s site? That’s what I was really hoping for. Also, any plans on making something similar for Performancing?

Great job on this plugin, BTW. Although, I was confused about what it did until I checked Ronald Heft’s page for the Google Analyticator and read his description, so maybe you should put a description on this page as well?

// Lucanos:

At the moment, this plugin simply inserts the required code into any served WordPress pages so that the StatCounter site can track visitors to your site.
Displaying stats, would either require insertion into the body of the page (which I guess would be doable, but would only show the number of visitors – not graphs or any other StatCounter goodness), or a manual inclusion of the StatCounter Code into your page (as opposed to using this plugin).

I will look at mirroring the help document used on the original plugin author’s page. I guess, for me, it just made sense as it is, but then again, I had a bit more exposure to the code than most users.

11. Shakeb - July 13, 2006

Perfect Thanks,
I was using statcounter’s code on my website but sure this as a plugin is much better.

Best regards
Shakeb

12. Erick Schluter - July 20, 2006

I will have a go at it and report back in a while with my findings!

Love this whole ‘WordPress plugin’ thing!…Pretty fly!

13. Ryan - August 25, 2006

Few question;

Where does the JS show up on the page? Is it at the bottom/below the footer. Will the spiders be able to view code and backlink to statcounter with this plugin? Also, how does this make it more WC3 compliant.

Thanks for the great plugin,

Ryan

// Lucanos:

Hi Ryan.
The JavaScript is inserted inside the Head of the document.
I am not sure about backlinking to StatCounter, but I can tell you that this plugin does work – it’s working on this site right now!
Not sure about the W3C Compliance – I don’t recall claiming that this makes any page more or less compliant…

14. Moose - September 19, 2006

thanks! you rule!

15. Chris Simmons - September 26, 2006

This is great. I’m sick of having to remember to add the code to my header everytime I change/upgrade my theme. I updated the other day and was wondering why I had no visitors for 2 days. This plugin would have fixed that.

Works great. Good job!! :D

16. m a x g a l l i n a . i t » Blog Archive » StatCounter Plugin (Wordpress) in Italiano - November 10, 2006

[...] La pagina del progetto del plugin è questa per maggiori informazioni: http://blog.lucanos.com/2006/04/17/wordpress-statcounter-plugin/ [...]

17. Massimo Gallina - November 10, 2006

Luke… I found your Plugin very easy and comfortable. So I decided to translate it in my language (Italian) and to write a post with your plugin localized in Italian!

I linked your blog in the post… here you can view:
http://maxgallina.it/?p=67

If there is any problem (copyright or similar for example )I’ll delete my post as soon as possible.

Regards

Max

18. BlogCarta.com - November 14, 2006

Statcounter Plugin For WordPress…

One of the great things about WordPress is the wide variety of themes that are available for it. However, often when I change my theme, I forget to change the Statcounter code that I had to manually put into the footer.php file of my original theme. Th…

19. Kelley - December 14, 2006

I love this plugin. The documentation was great, and I had no problems configuring it.

20. A Glad Man - March 31, 2007

First of all, thank you for this great piece of code! Said that, I’m here asking you if there’ll be any possibilities to get a translation of this pluging for http://pmetrics.performancing.com/ stats service. Indeed, I only need something to avoid admin accesses counts.

In any case, thank you.

21. David - April 8, 2007

I am using WordPress 2.0.2 (I know need to upgrade) install and it works fine. Statcounter is a great plugin. Thanks for you effort in coding it.

22. lorry - April 14, 2007

Well so far it seems to work Thanks.

23. Noel - April 18, 2007

wow, that was seamless… thanks for the heads up on a great counter. It is a great asset. Any plans to have a page integrated into WordPress so as to be able to see stats from there (in the admin section)?

// Lucanos:

At the moment, there is no plans to integrate the StatCounter statistics page into the WordPress interface. Due to cookie control, session control, and other aspects of their site which would need to be worked around it would probably be more work than it is worth.
Doesn’t mean it’ll never happen, but just not right now.

24. Adrian G. - June 15, 2007

Awesome plugin, installation instructions were clear on this page and after I installed the plugin.

Thanks you for coding it!

25. Vic - August 3, 2007

This is a great plugin. This type of is priceless for the new kid on the block.

Thanks

Vic

26. Amilcar - September 17, 2007

Thanks, it took only a few minutes to set it up, Great plugin! no problems. Great work!

27. Lily - October 25, 2007

The plugin is great! I love it! One of the reasons I changed to .org is to have decent stats and your help was great there :)

28. meggan - November 6, 2007

Hi, I can’t download the file. It says I don’t have the right program. Can you help?

// Lucanos:

Right-click on the link and select “Save Target As” (or similar).
It sounds like your browser is trying to access the file directly and just doesn’t know which application on your computer should handle “Zip” (compressed) files.

29. orcn - December 14, 2007

hi,
this is a great plugin – thankyou!

I am also just wondering is there any way of making the statcounter code to appear lower in the page code rather than in the head portion of the code, for example just before the tag instead so as to keep the content highest up in the page code. This is where I would manually install it.

Thanks again,

30. chodirin - January 22, 2008

thank you. this is a great plugins.

31. Gisle - June 13, 2008

thanks, i had some problems with statcounter until i found this plugin, :)
i just made a link to statistic if anyone other than me is intrested in seein the pageloads. G

32. Andii - July 25, 2008

Thanks mate. I was wondering how to get the stats recorded on my hosted blog. Super easy plugin to install and configure. All tracking nicely :)

Andii