Create a post view counter in Blogger (aka Blogspot)

Post Views Counter

If you've ever wondered: How do I add Post Views Counter on my blog on Blogspot? And go find out how to do on the internet to follow. There are many tutorials on how to make a visitor counter on the internet, but most of them are not updated, or only apply to unedited themes.
If you are using a commercial or edited blogspot theme other than the original standard blogspot theme, this is what you are looking for.
But, why need to add your blog post view counters if you already have it on "Dashboard"? Blogging is fun, and most of blogger wants to make their blog unique and good looking. Its purpose is for our readers to see which of our posts are viewed by others. It is also for us - the administrator, to track the post views on the front of our blog and to know which of our posts receive readers' attention and interest. Blogspot blogs can now easily add a post view counter because Firebase provides FREE service for everyone! We can now easily create this  post view counter without worrying about servers or server code. Yes you heard it right, all BlogSpot blogs will now be able to display a dynamic count for individual pageviews. Follow the steps below to make it work!

Note: The postviews count wont change when you refresh the blog homepage but it will change only when you visit individual posts.

1. Creating your Firebase Account

Signup to Firebase with your gmail account.
*You will be redirected to your dashboard once you successfully signed up

Then, click "Creat a project" button to create your Firebase Project

Creating your Firebase Account

Choose a name for the project:

add a project

The result will look like this:

add a project

OK, now we will create the Database:

Click DevelopDatabaseCreat database.

Creat database

Select "Database" in the left menu ⇒ then Select "View" on "Realtime Database" ⇒ Rules:

Realtime Database

delete all and replace with the following code as shown below:

{ "rules": { ".read": true, ".write": true  }}

Click "Publish" button.

Realtime Database

The website will show a red warning "Your security rules are defined as public, so anyone can steal, modify, or delete data in your database" click Dismiss to ignore.
Now, return to Blogspot.

2. Add Post Views Counter in Blogspot Posts

  • Go To Theme ⇨ Edit HTML
views Counter in Blogspot

  • Find top.showAuthor in html or you can find it with CTRL+F and write  top.showAuthor then Enter.
There are two (or three) locations that appear "top.showAuthor". At those 2 or 3) positions, paste the script above all top.showAuthor as shown below:

<a expr:name=''/> <i class='fa fa-eye'/> <span id='postviews'/> Views

First top.showAuthor like this:

views Counter in Blogspot

Second top.showAuthor:

views Counter in Blogspot

Third top.showAuthor:

views Counter in Blogspot

Paste This Script above </Body> in your html as shown below
<script src='' type='text/javascript'></script> <script> $.each($("a[name]"), function(i, e) { var elem = $(e).parent().find("#postviews"); var blogStats = new Firebase("" + $(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; = $(e).attr("name"); isnew = true; elem.text(data.value); data.value++; if(window.location.pathname!="/") if(isnew) blogStats.set(data); else blogStats.child("value").set(data.value); }); }); </script>

Now just replace the highlighted line with your Firebase Project ID.

views Counter in Blogspot

Save the script and then you can see the result.
Previous Post
Next Post
Related Posts