Automattic Stats for self-hosted WordPress

The new Automattic Stats plugin is available for download. It lets self-hosted WordPress bloggers use the exact same traffic metrics system we provide to users. It tracks post and page views, referrers, search terms, and clicks on your external links. It takes moments to install if you already have a WordPress blog and a API key. And it’s totally free.

Although the code is almost exclusively my work, I must give thanks for Matt‘s guidance, Barry‘s systems wrangling, and Rudy’s barbecue, each of which were indispensable.

The rest of this post will cover technical details of the system, how it works and why it’s cool. If you have a question I didn’t answer, leave a comment and I’ll do my best to answer.

How does it work?

The plugin adds a tiny image to your blog () and that image is hosted on our servers. Every time your blog is viewed by a browser with javascript enabled, the browser downloads that image and we see a new line in our server logs. We then process the server logs and insert the data into a big MySQL database that we use to generate the lists and charts on your stats page.

There’s a little more to it than that. The plugin adds the post ID and referrer to the image URL so we know what the visitor is looking at and where they came from. We examine the referrer and if it looks like a search engine, we sift out the search terms and save those instead. Our servers also communicate with your blog from time to time, such as when you update the title of a post.

What makes it fast?

When you run your own stats system, your blog server has to do a lot of extra work to track each visit. We take that load off your server to keep it snappy.

By serving the javascript from, we take advantage of the browser cache so that no matter how many blogs are visited, the script is only loaded once per week.

Clicks are reported asynchronously. Rather than the more common method of mangling URLs and forcing the visitor to wait during a redirect, the click stats are tracked using elements of AJAX. Your hrefs are safe and your visitors experience no delays.

The tracking gif loads fast because infrastructure just plain rocks.

What’s with the smiley face?

When we started developing stats for in 2005, Matt thought it would be cute. That’s his artwork.

No doubt, people will want to hide the smiley face. There are wrong ways to do this. Basically, anything that causes the image not to be loaded by the browser will break your stats.

Applying “display:none” to the image will break your stats. Don’t do it. If you want to hide the smiley face, add this to your stylesheet:


Why do my links point to

All stats reports are rendered by our servers. We designed it this way for a lot of reasons. It’s faster this way because your server doesn’t have to connect to our server every time you look at your stats. It’s also better because we can update the reporting UI without forcing you to upgrade your plugin.

How much traffic can you handle?

The stats hardware is currently handling millions of views every day and we’re nowhere near capacity. We built this system with growth in mind. The software is ready to run on as many servers as we allocate for the purpose. Growing pains are inevitable but if we’ve done our job, you will never feel them.

Can I install this on my non-WordPress sites?

The short answer is that the system only supports WordPress blogs.

The long answer is that anyone with a thorough understanding of WordPress and XMLRPC could clone the plugin to work with other blogging platforms. I can’t prevent it, I won’t discourage it, I do expect it, and I don’t even mind it. There are pitfalls, however, and I do not plan to document the requirements. Here be dragons.

Anyone found abusing the system, causing undue loads on the servers, or inflicting headaches on me or Barry or anyone else, will be subject to having their API Key revoked and their name written in giant, fiery letters across the night sky to be cursed by all who see it. Please don’t abuse this free service.

Why does the date change before/after midnight?

To keep things fast and consistent, we are ignoring time zones and keeping all stats in UTC.

Published by

Andy Skelton

Code Wrangler Automattic

88 thoughts on “Automattic Stats for self-hosted WordPress”

  1. Andy,
    A handy thing would be if there was some way to link back (get back) to my blog instead of hitting back a few times…

  2. This is sweet! If i have more than one WordPress self hosted blog can i use this on both of them? Or is it just limited to one blog per user?

  3. This sounds excellent… as a member I have become accustomed to the Stats provided on this service… I’ll give it a go… by the way, does it ignore hits made by my own server IP? when I’m visiting or updating/viewing pages?

  4. I use long time Counterize and a very happy with this. Its shows al I need to see the traffic to the site, so I see no reason to get over.
    All is’t a good plugin.

  5. My blog is located on my own site. When I select Dashboard / Blog stats, it asks me to sign into the WP site. Consequently, I went and got a WP API, and inserted it into the plugin.

    My expectation is that the stats will reflect the blog on my site, NOT the one I had to sign up for at the WP site. Is this correct? Call me dumb, but I’m a newbie.

  6. Hmm. That can’t be true. When I sign in from Dashboard, it tells me I have no blogs yet.

  7. Hmm. When I log in to get stats, it takes me to the WP site, where I’ve signed up, but where I don’t have a blog.

  8. Pingback: the so called me
  9. Andy, thanks so much for this plugin! I downloaded it the moment I saw it and waited impatiently the first twenty minutes for stats to appear. Okay. I didn’t wait. I gave up and took my kids to the park. But what do you imagine was the first page I checked out upon my return?

    Now that you’ve got this going on, my chief complaint about services like Technorati’s “authority” ranking could be dealt with through this tool. If WordPress can effectively provide this service on a cross-blog-platform basis, metrics like number of comments, number of inbound links to actual posts, and site traffic could actually be combined to give a real “authority” ranking based on real data that is much harder to game.

    Here’s hoping!



  10. I have problem getting my API key to work with the stats plugin. I am sure the API key is correct and valid as it’s being used for Akismet.

    Could it be the WordPress version?

  11. Excellent. Now I can get really depressed about how few people read the content. Seriously, thank you for the hard work!

  12. Nice plugin, but you spelled “sarsaparilla” incorrectly on the dashboard screen (the one that displays before any stats are counted).

  13. You might also want to add the attribute border:0 to hide the smiley face image, this obviously depends on the stylesheet of each individual blog but in many cases, including my own, people will see a tiny box in the bottom left corner of their screen if they have a border around images by default.
    Hope this is useful feedback. Jono

  14. Pingback: Morning Brew #1
  15. Pingback:
  16. it’s nice!
    thanks for your effort

    but is it possible to release all request methods of wpStats XMLRPC call?

    because I wanna add the stats information to my blog sidebar, such as: total views, today views…etc.

    thanks again :]

  17. Ah, now I finally know what that smiley face actually means. I’ve seen that smiley face occur at many blogs here and there and always wondered what the heck it was for. Now, at last I know. What a strange coincidence – that I’ve managed to stumble upon this blog and find out what that smiley face is all about. I’m keen to take a look at a system like this – so, let me see how I can use what you’ve made here to get some decent, proper, results for my blog.

  18. I checked my WP blog and saw the API keys which is responsible for this auto-stats. I saw BLOG STATS at my right nav links with a number of hits. Am I seeing the right one? Can I customize it so it will show some sort of a line graph or something or is it fixed?

  19. There seems to be an inconsistency between this post and the one on about how to hide the smiley. Could you please email me the answer and correct one of them?

    You say “Applying “display:none” to the image will break your stats.”

    But at it says “Can I hide the smiley? Sure, just use display:none. ”

    Please advise.


  20. Anyway we can get a fix that lets us change our timezone? I’ve tried other ways to track stats and this plugin is the best, but I need to keep the others just because of the time issue.

  21. Never felt this much relief about such a user firendly stats tool. I’m not a technical person but has found this tool handy. Good work, I hope you never remove the service, otherwise we would donate to the survival of this powerful tool.

  22. @Jeffrey, I’m pretty sure Andy is also the one that later wrote that FAQ entry, so “display:none” actually turned out to be OK for modern browsers.

Comments are closed.