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 yoursubdomain.appspot.com.

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 http://popular-posts-for-blogger.googlecode.com/svn/trunk/ popular-posts-for-blogger-read-only

Go to the popular-posts-for-blogger/popular-posts-for-blogger subdirectory and edit the getfeedstats.py 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 http://yoursubdomain.appspot.com/reports/analytics.

In your website or blog, where you want the widget to show, paste this code:
<h2>Most Viewed</h2>
<ul><script src='http://yoursubdomain.appspot.com/reports/analytics' 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.

33 Responses to "Blogger: Most Popular Posts Widget (Google Analytics)"

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 http://popular-posts-for-blogger.googlecode.com/svn/trunk/ popular-posts-for-blogger-read-only

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

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!

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

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 http://www.we-are-all-robots.blogspot.com/

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.

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

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

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!

Was looking for this, thanks for sharing tutorial :D

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.

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

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?

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.

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

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

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.

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.

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

amigo, fantástico seu blog e suas dicas

abraços
sex shop
sexshop

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

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

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

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

 what is a "check out"?



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

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

Come and visit my Site: http://www.lifebeyondlimits.info/

Thank you so much.

-jayryan09-

did you consider doing a google search? 

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

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

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 ... http://app.lorem-ipsum.jp/jisko/?module=RamonaRife&params=19775

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 ... galilee.ezpt.kr

I built something like this that relies on Google Analytics instead... http://popularposts.benguild.com

  Subscribe to replies to this post

 
This conversation is missing your voice. Your feedback is appreciated.
Post a Comment


You can use some HTML tags, such as <b>, <i>, <a>

If you see a message that says "your request could not be processed" press preview first and then post.
 
You can follow the discussion of this post by subscribing.


 
You are free to include information from this article on your own site if you provide a backlink. You can use the following markup:
<a href="http://www.myoutsourcedbrain.com/2009/11/blogger-most-popular-posts-widget.html">Blogger: Most Popular Posts Widget (Google Analytics)</a>