Nov 1, 2009

Blogger: Most Popular Posts Widget (Google Analytics)

google analyticsThere are several widgets for wordpress to show most popular posts, however, as far as I know, there is no good widget yet for blogger. In my last article, I explained how to set up a blogger widget that shows most popular posts based on feedburner statistics. In this post I explain how to create a widget for your blogger blog that shows most viewed posts based on google analytics statistics. The set up is very similar to the previous widget. A prerequisite is rudimentary knowledge of python. Again the warning: the installation is a little bit more intricate than other widgets on this site. I think anyone, with some patience should be able to do it, however if your computer skills are very limited, don't try it.

Image credit: wikimedia commons.

I found actually widgets for blogger that show most popular pages. One is from feedjit shows most visited articles during a day. There are several implementations of popular post widgets that show popular posts by number of comments, such as this one, which works with google pipes. Now, in my opinion, one day of traffic doesn't really give too much statistics to give useful information about which of your pages are most popular. As for the other widget, I don't want popular posts by comments, I want just the most visited ones. There is postrank, which shows popular posts measures of post submission to social bookmark sites such as slashdot or digg, however it would be nice to have a widget that shows most visited pages.

The widget I present here uses google analytics statistics to list most viewed posts. You'll need a google analytics account and the tracking code active on your site for it to work.

Installation of this widget is similar to the previous popular post widget with feedburner.

You can host the code on any site, however in this walkthrough I assume you use google app engine. If you don't have one already, you need to create a free account on google app engine. Hosting your files and web applications on google app engine brings you the advantages of a low latency content delivery network (CDN) which can make your site load faster and for this implementation of the most popular posts widget you need an account. You'll have to choose a domain such as

If you don't have it already install python. Download the app engine python SDK for python.

Download the source code of the widget. You need subversion for this. The command for checkout is this:
svn checkout popular-posts-for-blogger-read-only

Go to the popular-posts-for-blogger/popular-posts-for-blogger subdirectory and edit the file (use an editor or IDE that knows python, such as eclipse, vim, or kate). Search and replace myoutsourcedbrain for your feedburner uri.

Upload your code with the google app engine SDK. Still in the same directory type:
appcfg update .

If you did everything correctly you should now be able to see the javascript at

In your website or blog, where you want the widget to show, paste this code:
<h2>Most Viewed</h2>
<ul><script src='' type='text/javascript'/><noscript>most popular articles by feed views</noscript></ul>

Enjoy. Please leave a comment below for questions and suggestions. If you have ideas for any improvements please tell me.


  1. A little help...
    You wrote,

    Download the source code of the widget. You need subversion for this. The command for checkout is this:
    svn checkout popular-posts-for-blogger-read-only

    How to download the source code? Really need this widget...please help..

  2. Hi Roldan,
    analytics makes it complicated for users to download or share their data (at least for blogger users) that's why installation of this widget is a bit tricky.
    Note that my code works as it is but that it could easily be improved for better functionality.
    Now to your question. There are several graphical interfaces to the subversion version control tool, including tortoise which runs on Windows operating systems. However, to make it easier, I just provided a download at google.code.
    At the next step, when editing the files, be careful about the editor (see my remarks). Don't use Windows Notepad!

  3. Google analytics is a must for all serious bloggers
    Besides it's free, it has lots of useful features about our blog/site

  4. Hi, I've put the code up on appengine and the logs show : No module named gdata.auth. Any idea what could be causing this? Also I'm not sure what my blog's uri would be. It's at

  5. Hi Oliver,

    Sorry for the delay. Just back from holiday.

    Thanks a lot for your question. I should have mentioned it in the post.

    You need to put the google data api client in your python path. The simplest way to do this is to just copy the gdata directory from the api client library to your project's top directory, where the python scripts are located (popular-posts-for-blogger).

    This is necessary on your local machine. You don't need to upload the gdata library, however, because on google app engine the gdata libraries are already available.

    For the google analytics script (getmostviewed.pyyou don't need any blog url. You need your google account with password together with your website profile ID. A fast way to get the profile id of your website is at Data feed Query Explorer.

    Nice blog of yours, btw. Happy holidays.

  6. nice info,. many thanks..
    this is what i need

  7. thats what i was looking for! thank you @Benjamin.
    could you please write an article about how to use subversion?

  8. i think this is a good idea,i have spend lots of time on finding this widget,maybe i have to learn how to use google apps.
    sorry for my poor english.
    nice job!

  9. Was looking for this, thanks for sharing tutorial :D

  10. Download the source code of the widget. You need subversion for this. The command for checkout is this:

    What widget? Why you need subversion to download a widget? Where do you enter the command?

    This is one of the most cryptic tutorials I have ever read. Can you please elaborate a little, exactly what needs to be done? You are just assuming, everybody knows everything.

  11. thanks man for the tutorial~
    I think you should make same tutorial but just using the blogger stats~that would be nice~thanks~

  12. it could be interesting if you cane make same tutorial but using the stats in blogger, can it be done through this tutor in the first place?

  13. Hi. I keep getting a server error. The dreaded 500. I found a suggestion that it could be the request is timing out. Any idea of a workaround. Thanks.

  14. @Anonymous: Subversion is a program. I give even links to several sites that explain it and others where you can download it. Don't expect me to do everything for you. Look at the beginning, if you don't have some basic computer literacy, don't try it.

  15. @Marcus McElhaney: You need to give me some more to go on here.

  16. Frustrating. Looks like you have indeed cracked the correct way of doing it, but it turns out to be nowhere near apt for the non-savvy :'( In any case thanks for sharing the knowledge.

  17. I wrote several articles about popular post widgets. Some are much easier to install, just copy-pasting. Try one of the other widgets: Blogger: Most Popular Posts Widget (Feedburner) and Widgets for Most Popular Articles on Twitter, Digg, Delicious, Propeller, and Reddit.

  18. Awesome!!Thank you so much for this great information.i really enjoyed your post a lot.Keep writing!!

  19. amigo, fantástico seu blog e suas dicas

    sex shop

  20. Thanks for this script.  Is there a method to also get the thumbnails for each post? 

  21. There are some scripts out there, if you search a bit. It could be integrated with this code.

  22. Thanks, I actually hacked out a solution by cannibalizing both your scripts and parsing my rss feed for the thumbnails.

  23.  could you send the code for google?
    I can not figure out subversion

  24.  what is a "check out"?

    could you help create a file for google?
    I cant figure out after create a account

  25. For Blogger Users. I have a beautiful Different/Multi Colored Popular Post With Hover Effect Widget In Blogger.

    Come and visit my Site:

    Thank you so much.


  26. did you consider doing a google search? 

  27. It's a shame you don't have a donate button! I'd without a doubt donate to this superb blog! I guess for now i'll settle for bookmarking and adding your RSS feed to my Google account.
    I look forward to new updates and will share this blog with my Facebook group.
    Chat soon!

    My site dental plans
    my page - individual dental Plan

  28. Good blog you have got here.. It's difficult to find high quality writing like yours these days. I honestly appreciate people like you! Take care!!

    My blog post; PBA Dental

  29. I'm extremely inspired along with your writing abilities as smartly as with the structure to your blog. Is that this a paid theme or did you customize it yourself? Either way stay up the nice high quality writing, it's rare to peer a nice weblog like
    this one nowadays..

    Feel free to surf to my web page ...

  30. Thanks for developing this site. The stories here
    cost reviewing many times over in order to refresh
    us time and time again to do excellent and beneficial things and encourage
    or affect others to do the same.

    My web-site ...

  31. I built something like this that relies on Google Analytics instead...

  32. Simpson told her she Michael Kors outlet online sale would like the ending. Over the years Lisa had an on-and-off relationship with Simpson, but it would be closer in some ways than the one she had with her father.

  33. Thank you very much for posting and sharing this great article. It is so interesting for me boneka full body and beneficial to all people who read obat penghilang tatto permanen


  34. Very awesome post , i am really impressed with it a lot
    When I first visited your blog, I liked the concept of your blog posts. It is very well portrayed as well as depicted

    Arts de la table
    recette tiramisu
    gateau aux pommes
    creme patissiere
    creme anglaise
    recette chantilly
    recette gaufre
    recette galette des rois