Yes you heard it right, all BlogSpot blogs will now be able to display a dynamic count for individual pageviews. We can now easily create this post view counter without worrying about servers or server code. With a free service like Firebase you can now create dynamic and data-driven plugins for blogger without worrying about backend development. Firebase was launched in April 2012 and since then it had been the hub for developers. Amazingly this free plan gives you 10GB Free bandwidth and 5GB Free storage. Which in our case is more than required! We had been lucky to utilize this free service for blogger platform and create some amazing scripts with the help of our developer Ahmed Nasir. Today's tutorial will help you to install a dynamic script that will automatically increment its initial count value when a visitor views your blog posts. The counter data will be stored on a free database provided by Firebase. Lets first see a demo!
Note: The postviews count wont change when you refresh the blog homepage but it will change only when you visit individual posts.
1. Create your Firebase Account
In order to gain access to a free database and be able to keep a backup of your postviews counter data, you must sign up for a free account at Firebase.
Fill up the easy steps sensibly and then once your account has been activated, you must create your first Firebase database.
2. Create a Firebase Database
You can create 2 firebases. At present just create one, we will guide you later in coming posts about amazing things you can play with this free service.
- Towards the bottom right side of your account, you will find the following submit box.

2. Inside this box input your website name. In my case I inserted mybloggertricks and this generated the following firebase URL: https://mybloggertricks.firebaseio.com
3. Finally hit the create button and note down your firebase URL because we would need it later in this tutorial.
3. Installing Postviews Plugin
- Go To Blogger > Template
- Backup your template
- Click Edit HTML
- Tick the box "Expand widget Templates"
- Search for ]]></b:skin>
- Just above it paste the following CSS code:
/*-------- Post Views ----------*/
#views-container {
width: 85px;
float: right;
}.mbtloading {
background: url('http://4.bp.blogspot.com/-PZMStRDcchY/USOp3xFp4yI/AAAAAAAAJOo/rm5FSsaSKh0/s320/mbtloading.gif') no-repeat left center;
width: 16px;
height: 16px;
}.viewscount {
float: right;
color: #EE5D06;
font: bold italic 14px arial;
}.views-text {
float: left;
font: bold 12px arial;
color: #333;
}.views-icon{
background: url('http://4.bp.blogspot.com/-_dXedKDHIws/USOp369zEPI/AAAAAAAAJOs/Cv3fTZUaBTU/s1600/postviews.png') no-repeat left;
border: 0px;
display: block;
width: 16px;
height: 16px;
float: left;
padding: 0px 2px;
}
Customizations:
- To change the text color of the numeric count, edit #EE5D06
- To change the plugin alignment, change right to left.
7. Next search for </body> and just above it paste the following JavaScript code:
<!-- Post Views Script by MBT -->
<script type='text/javascript'>
window.setTimeout(function() {
document.body.className = document.body.className.replace('loading', '');
}, 10);
</script>
<script src='https://cdn.firebase.com/v0/firebase.js' type='text/javascript'/>
<script>
$.each($('a[name]'), function(i, e) {
var elem = $(e).parent().find('#postviews').addClass('mbtloading');
var blogStats = new Firebase("https://mybloggertricks.firebaseio.com/pages/id/" + $(e).attr('name'));
blogStats.once('value', function(snapshot) {
var data = snapshot.val();
var isnew = false;
if(data == null) {
data= {};
data.value = 0;
data.url = window.location.href;
data.id = $(e).attr('name');
isnew = true;
}
elem.removeClass('mbtloading').text(data.value);
data.value++;
if(window.location.pathname!='/')
{
if(isnew)
blogStats.set(data);
else
blogStats.child('value').set(data.value);
}
});
});
</script>
Make this change:
- Replace the highlighted brown line with your firebase URL (Step#2). Make sure you replace it correctly by taking care of forward slash (/)
8. Now one last step. Find this code:
<data:post.body/>
Note: If you are finding multi occurrences of the same code then choose the first occurrence.
9. Just above it paste the following HTML,
<!-- Post Views Counter by MBT-->
<div id='views-container'><span class='views-icon'/><div class='views-text'>Views:</div> <div class='mbtloading viewscount' id='postviews'/></div>
You can replace views: with any text you like.
10. Now the final step, paste the following jquery link just below <head>
<script src='http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js' type='text/javascript'></script>
11. Hit save and you are all done!
Visit your blog and press F5 (refresh page) to see the counts dancing just perfectly! :)
Copyrights
Developers and niche bloggers are most welcome to share this Plugin with their readers and friends. Please attribute the credits back to MBT blog as the only favor in return. It takes hours of efforts to write and debug these scripts. This plugin comes under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License.
Need help?
We just hope this plugin adds new fuel to your blogger powered blogs. We tried best to keep it working as efficient as possible. You wont run out of bandwidth as long as you create your own Firebase accounts and not use ours (our firebase url).
This plugin will display views only once pages are visited. It is not synchronized with your Google analytics stats data, therefore it will only display correct views for the new posts that you publish.
Let me know if you needed any help. We have some more interesting scripts coming up this week. Stay tuned! Peace and blessings buddies :)
Don't forget to try:
Filed Under: Blogger Widgets and plugins
If you don't want to get yourself into Serious Technical Trouble while editing your Blog Template then just sit back and relax and let us do the Job for you at a fairly reasonable cost. Submit your order details by Clicking Here »









78 comments:
thanks I was looking for this to add to my blog http://sreyaghoshalfansclub.blogspot.in/..
I would definitely try this on my Blog of CRICKET GAME Patches.
http://a2-studio.blogspot.com
Well Mohammad you have created this with great efforts we will follow.
Thankss
...▄▀▄▀▄▀▄ ▀ProBloggerTricks▀▄▀▄▀▄▀▄...
Thanks Qasim! I was searching it from a long time. Firebase is really great. :)
Thanks Qasim Brother!
I like this but it is very slow. I was use this my blog:
http://composition-paragraph.blogspot.com/
Wait why mine is just displaying loading icon instead of views number. Is it fine if I put it next to the post-label
It's really very helpful. Thanks for the post.
http://www.24xhtml.com/2013/02/use-unique-facebook-cover-photo-for.html#more
Will the count begin from zero or will it display the actual number of pageviews the post got ?
@Tanmay Kapse
According to what I see right now. It's counting from 0. I maybe wrong though. :D
Thanks. Didn't find this too attractive/useful. Most of the users have slow net connection undefinedincluding me ;) ). So the 'views' stats kept loading... loading... :)
Yogi
Art of Living Universe
Nice tutorial bro i considered that types of plugins can only be used on wordpress but amaze to know we can alo use it on blogger!
http://www.itstarz.com/
http://www.freeallstuff.com/
Great break through to blog and bloggers. Thank you for soding and sharing..
Regards
Gireesh
CoreBlogging
thank you
Amazing, But i want to know how can i add facebook + blogger comments box together with admin reply button Please reply. You are not reply my any queries, I hope this time i got my answer
Awesome tricks thanks for sharing this on web :)
Regards
Rahul Kashyap
Blog: SDMMovies.com
that was a nice one....was waiting for this kind of post views plugin !!!!!!!!!! TricksWorld 99
Very basic thought yet never introduce, will certainly help blogger hosted blogs to add this good feature. Great innovation MBT !
I could not refrain from commenting. great brother i like it and add on my blog !
Download books and drivers
Thank you Muhammad, this is an useful post, i thinsk i'll add it to my Blog!
_ ¦ _ ¦ _ _ ¦ _
Blogging iGeek
_ ¦ _ ¦ _ _ ¦ _
I wanna try this..
www.MoreBlogTools.com
Really cool trick.... Allblogtools released a similar widget but it was a failure. Now you rocks :D
In And Out 2013
I was in search for this since long time
Installed and working great ;)
Great Work Bro :D
But the drawback is that this does not show the actual Views of the post
Really a very helpful plugin for bloggers. I am also going to use this plugin for my website HiFiFun.Com All Kind of Tips and Tricks.
Added it in My blog... Thanks...
Great plugin, but I have one problem, it interferes with my post summary text. I would like to move it away. Can you help?
Blog: www.togetheragain2013.com
Mohammad sir,
I am very disappointed to say that blogger is not replying me at all. I did whatever you said and I didn't received even a single email from them.
One more blunder, my traffic has fallen from 800 pageviews a day to just 70. Please help me out sir! How to get my traffic back?!! I need your help!
Another great article keep it up bro :)
Great!
http://www.4dcores.com/
Can i use the same firebase database for Multiple blogs?
I corrected my above issue. I added padding to achieve space between my post summary and the counter.
Nice tutorial bro. thanks for the Code
Webhosting Pakistan
seriously, you guys are amazing and thanks for this plugin...but it's not first....i has used a view counter widget in past, which was php based (you have to upload that file to a php hosting to use that plugin).
@Tan Nguyen
You might have forgotten to replace the firebase url in step#3. Please create a firebase and then replace the url in the code above. Make sure you have not disabled javascript in your browser.
:)
@Tanmay
I have mentioned in the post that it will count from zero and wont display google analytics stats.
:)
@yogendra
I guess if you have a 100kbps Net speed then it must work. If you have a net slower then this, then have mercy on yourself! :p
@Sumit
Whenever I read your comment, I always try to reply captain. :)
For the comment box of facebook with blogger please read: Add Facebook and Blogger comments inside tabs
@kumar
That means a lot :)
@levis
Previously they would host it on their servers but that caused bandwidth problems, thats why it never worked earlier :)
@haider
the drawback is true only for older posts but it will show correct views for the newer one. Glad you liked it captain :)
@J and K
Glad you figured it out. The plugin could easily be positioned and aligned by adding margin property to the class:
#views-container
All CSS is available. For more help do let me know :)
@Mehul
I feel bad buddy. If they have not yet replied then may be your case was a serious one. I would encourage you to not loose hope and create a new one with far better unique content. You must introduce your own style and offer us all something new. I am sure this way you will enjoy your work even more like you always did. About the traffic its natural that it will drop because the domain content has been removed.
You can create a new blog and use the same domain for it as mypremiumtricks. You will be able to refer your readers back to a new blog but the search traffic can't be diverted because your pages are removed.
@Aravind
You can use it for all your 100 blogs! Enough badnwidth and storage there. :)
@Hardeep Asrani
You are right buddy. That php plugins did exist as I mentioned earlier in my comment but a Javascript based plugin has been introduced first time thanks to the free service of firebase else even we would not be able to achieve this. :)
Really Awesome I Like your This Post So Much Because I am sharing For this Plugin So many Times And i Got Some 4 Or 5 Article But All Script Is Not Working but Your Script Is Working thank you For Sharing man
Etech Entertainment
Online INdia Media Website
Realy Osm... But its Not Work On My Site i Did All The Steps Plz Help me,, Thanks
Awaargi
yes bro meri site per work ni kr rha jsy loading hi ho rhi ha?????
goog dear
www.mobile9plus.com
Wow..great..really really I like it's my favorite,thanks Mustafa happy nice day 4U and family..from INDONESIA with smile.
Hehehe... thanks bro.
Yes, I have net speed of 100kbps
Bas kabhi kabhi dagaa de deta hai ;D
www.artoflivinguniverse.org
hi
its not working on my site
http://www.idlebrain5.in/
https://idlebrain5.firebaseio.com
please help
@nani kk
I see that you have not added jQuery script. Please add this to your template before the views code.
http://codepaste.net/9bcc4m
Like your post
Free Premium Acounts and Cookies - www.codeswork.tk
Thanks for worderful info. Like your blog
Great plug-in! Is there a way to place it in the post header? My blog www.togetheragain2013.com uses a large 1st post image. When loading, the counter flashes then disappears behind the image. It doesn't show in any post then.
Thanks,
John
@J and K .. It is because you have some problem in your existing javascript. If you move the post-views script above the script which is for avatar then it will work.
Found it, fixed it. Works great!
UPDATE
I forgot to mention the step of adding the JQuery script in your templates. If the image keeps on loading then it is because you have no jquery installed in your template. I have updated the tutorial please read Step#3.10
Thanks Ahmed for remining it :)
Masha Allah ,jo b krte ho kmaal ka krte ho , Mohammad Mustafa Ahmedzai , very nice I Hate Cracks
Dear Mohammad,
Its good to visit your site again and again & i not get any solution of my query, this tutorial is working for other viewers but not running on my blog like your other tutorials. I again request you to see the problem. www.tallyssolution.blogspot.com
Regards
Great work brother, keep it up :)
@Ahmed Nasir
thanks now its working
Thanks
------
Ahmed Blog
Assalaamualaikum Brother. I want to say that you are a superb coder and developer. I didn't know that Blogger can be so beautiful with the template that you have just installed. I'm commenting after a long time because of some personal reasons. Seeing you blogging makes me feels good. I'll continue with my blogging and hope to make some money off Google Adsense.
I have a question. I want to know how much can a person earn if he is using Blogspot domain. Please reply
@atif
Thanks for the kind feedback :)
@Sumit Kumar Gogawat
Buddy apply it on your blog first and then let me know. I visited your site but didn't find it. Please first add it.
For other tutorials you may post all your queries in template customization recipe. I will answer it there soon.
@Goonoo
W.salam brother,
Its indeed an honor and its a greta pleasure that you are commenting after a long time. I wish you keep visting and sharing your ideas with us.
About Adsense I would say its earning is not dependant on what platform you use, be it joomla, wordpress or blogger. your earnings depend on your traffic and CTR. I became a premium Adsense publisher at Blogger so the opportunities are hell lot. :)
@Mohammad Mustafa Ahmedzai Dear Mohammad, I have already apply code on the blog and checked twicely, thricely. But i think something happen wrong with my blog. Because when i edit or add a widget my blog did not accept it. I was tried your lots of tutorial on my blog but every time its not working.
If you check my blog from my email id or password, then i send to you via email. Please help me.
I like the concept very much, but have removed it for now because ity does not load very fast...will try again later.
I added script after head but the views is stills loading.
this is my blog url.
www.wallpapersfever.com
Thank very mushhhhhhhhhhhhhhhhhhhhhhhhh شكرا جدا
@Gurpreet Dhillon
on my blog still loading too...
this is my blog => http://bigtitlovers.blogspot.com/
Awesome MTB I have done Here's My Blog
http://mastereffects.blogspot.in
ijin nyimak brooo,sekalian ijin folliw.mau copy paste ya tutorialnya.sekalian follow saja.
license to practice the tutorial guys, follow all licenses and permits would paste copies of most of the article behind the blog follow me
i just use this.. simple and excellent.. http://graddit.com/ratings-widget :)
thanks for the tutorial.
ایک مسئلہ درپیش ہو گیا ہے۔۔۔ میں نے اس پلنگن کو انسٹال کر لیا ہے لیکن اس سے متعلقہ پوسٹ کے کو شروع سے دکھا رہا ہے۔۔۔۔۔۔۔۔۔۔۔ فرض کریں بلاگر کنٹرول پینل میں میری پوسٹ کے 100 دیکھنے والے ہیں لیکن اس پلگن میں 0 سے سٹارٹ کر رہا ہے۔۔۔۔۔۔۔۔ کیا یہ ممکن ہے کہ وہ کنٹرول پینل پر سے بلاگر کے ویورز کو کاونٹ کرنا شروع کرے۔۔۔ ضرور بتائیے گا۔
سید آصف جلال
http://www.sadaemuslim.com/
nice code for my blogger and i hope for other friends and very nice Artical..Download Pc Games
It tried but it is not showing on my blog..Please help me out..
http://www.yourknowledgeportal.com/
Not showing buddy take a look and help please http://www.animeipics.com/
http://testblogmutnaa.blogspot.com/
NOT WORKING HERE EITHER,,, seems like firebase recently changed,,,
i'll try this to my blog,,
btw my blog using your template Salahudin Ayubi and i customize like your's
here http://www.depermana-share.blogspot.com
Very nice post
I also add my blog
http://clickbrunei.blogspot.com
Thank you for this it works well but it shows wrong visit nos because in blogger view count it shows as 434 nos. But in this way it shows 133 views. why it shows so different.
My Site: www.odishajobs.co.in
thanks a lot!
Click Here To add Comment
Your feedback is always appreciated. We will try to reply to your queries as soon as time allows.
Note:
1. To add HTML CODE in comments then please use our HTML Encoder
2. You can always Test the tutorial on our HTML Editor
3. No cheesy/spam Comments tolerated Spam comments will be deleted immediately upon our review.
Regards,
Mohammad