http://bloggertutorialtipstricks.blogspot.com/ 2005-01-01 monthly 0.8 Blogger Tips and Tricks | Blogger Tutorials | Widgets and SEO Tips

Blogger Tips and Tricks is an Online Tutorials Blog For Blogger Tricks, SEO Tips For Bloggers, Gadgets, Widgets and Plugins For Blogspot.

Thursday 11 July 2013

How To Add Post Views Counter Plugin in Blogger?

Blogger Tricks, Views counter,
Blogger Tricks and Tips: How To Add Post Views Counter Plugin in Blogger?I am happy to inform you all that now you can show post views counts below your post title in blogger blog. You have no need of any server or server code to display your post page views. Recently I got aware with a free service called FireBase. By using this free service you can easily create a dynamic and data-driven plugins for your blogger blog and you have no need of any development skill. Firebase was launched in April 2012. Here you can get 10GB Free bandwidth and 5GB Free storage which is really more than enough for bloggers. In this article you will learn how to add a dynamic page views counter for individual posts in blogger. Before going to the tutorial you may be interested to see a demo!

Note: This plugin will only increment its count value when you visit individual posts but not by just refreshing your blog homepage. 

Create FireBase Account
To use this plugin and to store your database of your post views data you must need to sign up for a free account at Firebase.                    Signup at Firebase

Once you fill all the details and create your account, then you need to create your first firebase database.

Create a Firebase Database
1. At the bottom right side of your account page, you will get a following create box.


2. Insert your blog name in the text field. In my case I inserted bloggertutorialtipstricks.

3. Press create button. Once you press the button your firebase will be create as:
                                   bloggertutorialtipstricks.firebaseio.com.

4. Note down your firebase url in any text editor like notepad. We will need it later in our tutorial.

Installing Post views Plugin

1. Go to your blogger account then choose Template

2. Backup your template before doing any changes.

3. Click Edit HTML and  Expand Widget Templates.

4. Press Ctrl+F and find ]]></b:skin>

5. Just above it, paste the following css code.

/*-------- Post Views  ----------*/
#views-container {
width: 75px;
float: right;
}
.mbtloading {
background: url('https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXw_BcL9pQdMYZLyFz0CPJAmZCG31DJck1Ys08gTLb8Jneze3rVtMpvsCLNAyY4vtHsPQTwpNngLBJkEG3-A6p8QUXlzl-lAyjsYEJU03rIL03vlIlo1iI2XwnWka9Ysat6egqutMq57Wx/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('https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjYJGmNER4X5KWiEyPRrSkKNHQ6Jb7hV5RcCBPZgx3z5lTHrnp6w8AUxs4GxguOAw4mBO7b_ULeojUvvg_JLsW_2_6UBeoPFygNsz4xwZZtAiQwNsa17W7OP7Sd8xdiWI821DBM6fS5XP1z/s1600/postviews.png') no-repeat left;
border: 0px;
display: block;
width: 16px;
height: 16px;
float: left;
padding: 0px 2px;
}

Customization: 

Edit #EE5D06 to change the text color of the numeric count.

Replace right with left to change the plugin alignment.

6. Now search for </body> and paste the following code just above/before it.

<!-- Post Views Script by MBT -->
<script type='text/javascript'>
    window.setTimeout(function() {
document.body.className = document.body.className.replace(&#39;loading&#39;, &#39;&#39;);
      }, 10);
  </script>
<script src='https://cdn.firebase.com/v0/firebase.js' type='text/javascript'/>
<script>
$.each($(&#39;a[name]&#39;), function(i, e) {
var elem = $(e).parent().find(&#39;#postviews&#39;).addClass(&#39;mbtloading&#39;);
var blogStats = new Firebase(&quot;https://bloggertipstricks.firebaseio.com/pages/id/&quot; + $(e).attr(&#39;name&#39;));
blogStats.once(&#39;value&#39;, 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(&#39;name&#39;);
isnew = true;
}
elem.removeClass(&#39;mbtloading&#39;).text(data.value);
data.value++;
if(window.location.pathname!=&#39;/&#39;)
{
if(isnew)
blogStats.set(data);
else
blogStats.child(&#39;value&#39;).set(data.value);
}
});
});
</script>

Change the highlighted orange line with your firebase URL which you copied in step 4.

7. Now find this code:    <data:post.body/>

8. Just above this paste the following code

<!-- 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>

9. Replace Views: with any text you want to use.

10. Now paste the below code just after <head>

<script src='http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js' type='text/javascript'></script>

Press save template button.

Congratulation! You have successfully installed the post views counter for your blog.
Share this post
  • Share to Facebook
  • Share to Twitter
  • Share to Google+
  • Share to Stumble Upon
  • Share to Evernote
  • Share to Blogger
  • Share to Email
  • Share to Yahoo Messenger
  • More...

2 comments

  1. This comment has been removed by the author.

    ReplyDelete
  2. Replica Audemars Piguet Watches, combining elegant style and cutting-edge technology, a variety of styles of Replica Audemars Piguet royal oak Watches, the pointer walks between your exclusive taste style.

    ReplyDelete

:) :-) :)) =)) :( :-( :(( :d :-d @-) :p :o :>) (o) [-( :-? (p) :-s (m) 8-) :-t :-b b-( :-# =p~ :-$ (b) (f) x-) (k) (h) (c) cheer

 
© Blogger Tips and Tricks | Blogger Tutorials | Widgets and SEO Tips
Designed by BlogThietKe Cooperated with Duy Pham
Released under Creative Commons 3.0 CC BY-NC 3.0
Posts RSSComments RSS
Back to top