Using WP Super Cache with WordPress.com Stats

WP Super Cache and WordPress.com Stats are two very useful WordPress plugins. WP Super Cache provides static and dynamic cache functionality to reduce the load on your blog’s server, allowing larger amounts of traffic to visit without slowing the site down. WordPress.com Stats tracks visitors and gives valuable information on how users utilize your blog. If you plan to use both of them together, you should be careful though.

The Problem

The problem arises due to WordPress.com Stats’ behavior of not recording statistics for logged-in users. This is usually desirable, since these users are most likely yourself and other blog authors. This means that when logged in, a visit to your blog does not invoke the necessary JavaScript code to update statistics.

What happens when you have WP Super Cache enabled? If you visit a page that is not cached, a cache will be generated. If you are logged in at that time, the cached page will not have the stat updating code. This page will then be served to future users, whether they are logged in or not, resulting in lost statistics. This is a problem for all statistics tracking that relies on checking if users are guests or not.

The Solution

The solution is to check the option in WP Super Cache called “Don’t cache pages for logged in users.” This will cause cached pages to always be for guests only, and thus contain the stat updating code. Be sure to clear the existing cache after enabling this option to make sure the wrongly cached pages are gone.

Of course, this is not ideal if the blog has a large user community. In such a case, a different stats package should be used anyway. Google Analytics, for example, should work just fine on cached pages as long as the JavaScript is always present.

2 thoughts on “Using WP Super Cache with WordPress.com Stats

  • October 23, 2009 at 11:21 pm
    Permalink

    I was wondering what was wrong with the stats. And ive been searching for a while. Thanks for posting a fix.

    Reply
  • May 12, 2010 at 6:29 am
    Permalink

    Thankyou mate, first I thought something wrong with my site so the user won’t visit it anymore. Now I know that not true :).

    Reply

Leave a Reply

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