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 WordPress.com 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 WordPress.com 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 stats.wordpress.com, 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 WordPress.com infrastructure just plain rocks.

What’s with the smiley face?

When we started developing stats for WordPress.com 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:

img#wpstats{width:0px;height:0px;overflow:hidden}

Why do my links point to WordPress.com?

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.

Previous Post
Leave a comment

88 Comments

  1. nice. now I don’t need to go somewhere else to check the stats of my blog.

    Reply
  2. 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…

    Reply
  3. Andy writes about the tech side of things and some FAQs.

    Reply
  4. Looks great. Going to install it in a second :)

    Reply
  5. mark

     /  May 6, 2007

    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?

    Reply
  6. Best news of the year!

    Thanks!

    Reply
  7. Crowmanic

     /  May 6, 2007

    This sounds excellent… as a WP.com 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?

    Reply
  8. Harry

     /  May 6, 2007

    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.

    Reply
  9. Would this work with a wordpress MU installation?

    Reply
  10. Is this plugin only for WordPress 2.1.x available or can I use it with WordPress 2.0.x, too?

    Reply
  11. This is beyond stellar!

    Reply
  12. Yay! Finally!

    Reply
  13. interesting idea, I definitely need to check it out next weekend or so!

    Reply
  14. Thank you very much !!!
    It’s a very useful plugin, and i think every wordpress user should get it.

    Reply
  15. Twolane

     /  May 6, 2007

    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.

    Reply
  16. ridingfool

     /  May 6, 2007

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

    Reply
  17. Up and running, now to wait for those clicks to show up!

    Reply
  18. Twolane

     /  May 6, 2007

    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.

    Reply
  19. Andy, this is very nice. Thank you. :)

    Reply
  20. How do I go about getting my name in big firey letters anyway? Sounds like it could be amusing… ;)

    Reply
  21. 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!

    Regards,

    Rich
    BlogRodent

    Reply
  22. awesome stuff! …thank you!

    Reply
  23. 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?

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

    Reply
  25. sickink2

     /  May 7, 2007

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

    Reply
  26. jonolumb

     /  May 8, 2007

    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

    Reply
  27. Finally! Thank you for sharing your work.

    Reply
  28. Thanks for this plugin, I’m going to try and install it on my blog now :D

    Reply
  29. nice one!. i’ll try it now.

    Reply
  30. 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 :]

    Reply
  31. I am using Sitemeter and Google Analytics to get my stats but this plugin is worth looking into. I will download and try.

    Thanks.

    Ash

    Reply
  32. 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.

    Reply
  33. jacquivalenzuela

     /  May 6, 2008

    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?

    Reply
  34. Jeffrey

     /  May 15, 2008

    There seems to be an inconsistency between this post and the one on wordpress.org 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 http://wordpress.org/extend/plugins/stats/faq/ it says “Can I hide the smiley? Sure, just use display:none. ”

    Please advise.

    Thanks!

    Reply
  35. hellz99

     /  January 21, 2009

    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.

    Reply
  36. musadube

     /  March 31, 2009

    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.

    Reply
  37. @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.

    Reply
  38. grant8223

     /  November 14, 2012

    Please make a change to wordpress.com stats so that is can reflect your current time zone. Please!

    Reply
  1. Stats Plugin « WordPress.com
  2. Plugin de estadísticas basado en Wordpress.com « Javier Aroche
  3. ปลั๊กอิน: Automattic Stats for self-hosted WordPress « au8ust’s wordpress channel
  4. Blog Stats Plugin fr Wordpress at ogeeBloggin’
  5. Xrossblog » Geflüser: Wordpress.com Stats als Plugin
  6. blojer › Free Radio Linux. Explorando el límite entre arte y tecnología.
  7. Plugin de estatisticas para Wordpress: Dois bons plugins
  8. WP Plugin - Automattic Stats | Easy Wordpress
  9. Better WordPress Stats [problogger philippines]
  10. Automattic Stats for self-hosted WordPress : Losing it[1]
  11. Wordpress/Automattic: All you data is belong to us - h0bbel
  12. WordPress.COM Providing Stats for Self-hosted WP Blogs » Solo Technology
  13. WordPress Users: Less Spam and Better Stats · cavemonkey50.com
  14.   Homens-aranhas em blogs queimando - Fudeblog by Cesar Cardoso
  15. Ryan’s Journey » Wordpress Stats
  16. Worpress.com Stats Plugin | iface thoughts
  17. Automattic stats per il vostro blog in Wordpress
  18. Radiance Freq. · Automattic Stats
  19. Divi nozīmīgi spraudņi WordPress platformai @ krizdabz BLOG
  20. Sue’s Place - Controlled chaos » WordPress Stats
  21. WordPress Stats at SDJL.co.uk
  22. WordPress.com stats for your own blog at Holy Shmoly!
  23. WordPress 釋出官方統計程式 « 無聊人的無聊故事 - 站長有兩隻,搭訕前請先認明
  24. [Plugin] Automattic Stats
  25. ckunte.com | Automattic stats
  26. The Breathing Room » WIP progress + stats plug-in
  27. TechZOnline.net » Blog statistics for standalone WordPress users
  28. Automattic Stats | K-Squared Ramblings
  29. La domo de karotoj » WordPress-a statistiko
  30. e-piphany » Automattic Stats plugin for WordPress…
  31. Wordpress Stats at they made me do it
  32. The Nimble Books Blog » Blog Archive » Automattic Stats plugin for WordPress
  33. Automattic Stats plugin for Wordpress at Florchakh Dot Com
  34. Wordpress Stats Plugin » PINOYHACK.COM
  35. The New Google Analytics → The Jim Whimpey Weblog
  36. Staslive’s blog » Архив блога » Stats Plugin
  37. Morning Brew #1
  38. Weblog Tools Collection » Blog Archive » APAD: Wordpress Stats
  39. WeblogToolsCollection DE » Blog Archive » Wordpress Stats Plugin
  40. 我爱水煮鱼 » Wordpress Stats Plugin
  41. WeblogToolsCollection Español » Blog Archive » APAD: WordPress Stats
  42. the power of 3 statistic in wordpress will set us free
  43. h0bbel.p0ggel.org
  44. » Blog Archive » Contatore visite worpress ufficiale
  45. Pimpajoentje Punt Bee Ee » Blog » Blog Archive » Het Wordpress smiley mysterie
  46. Self-Hosted Wordpress VS Free Blogging - www.douglampi.com
  47. The ONLY thing wrong with WP-Stats at The bloody toe

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 1,665 other followers

%d bloggers like this: