How To Add Post Views Counter to Blogger

Add Post Views Counter to Blogger
Add Post Views Counter to Blogger
Why need to add a post views counter on your blog if you already have one on your "Dashboard"? Its purpose is for our readers to see which of our posts are viewed mostly by others. It is also for us - admins, to monitor the post views in the front end of our blog and to know which of our posts get the attention and interests of our readers. Blogger blogs can now easily add a counter of post views thanks to Firebase which provides FREE service for all! Follow the steps below to get it working!

Creating your Firebase Account

Signup to Firebase
*You will be redirected to your dashboard once you successfully signed up

Then, create your Firebase APP
*Don't forget to copy your Firebase App URL. Return to Blogger

More About Firebase

  1. After creating a firebase account create an app.
  2. Now click on the app name.
  3. Then click on Developer.
  4. Then click on the Database.
  5. Then click on Create New Database.
  6. After Creating A Database.
  7. Click on Cloud Firestore.
  8. Then select Realtime Database.
  9. Then click on the Rules tab.
  10. Now remove all code from the Rules tab and add new code:

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

And now click on the Publish button.
Now click on the Project Overview Setting.
Project Overview Setting
Now click on Project Settings.
Now copy the Project ID.
Project ID

Now add the Project ID. On YOUR-APP-NAME on this javascript code

JavaScript Code

  • HTML

Go to Blogger » Template » Backup your Template » and Edit HTML Copy this code then paste it before <data:post.body/> *or anywhere you'd like it to appear inside your Blog Post

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

You Can Change The Eye Icon By Changing Fa Icon Name

  • JScript

Find (ctrl+f) </body> Copy the following code and paste it before </body>

<script src='' type='text/javascript'/> 
$.each($(&#39;a[name]&#39;), function(i, e) { 
var elem = $(e).parent().find(&#39;#postviews&#39;); 
var blogStats = new Firebase(&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; = $(e).attr(&#39;name&#39;); 
isnew = true; 

Save The Template.


Coming Soon.

Final Words

There you have it! Until next time, happy blogging!
How To Add Post Views Counter to Blogger How To Add Post Views Counter to Blogger Reviewed by Admin on March 28, 2020 Rating: 5

1 comment:

Powered by Blogger.