How to add post views counter to blogger

No comments
How to add post views counter to blogger

we are brought a new tutorial on blogger for you today.This applies to the blogger.Many people come to a normal blog.And many people are concerned about the views of the blog.If there are too many views on the blog, many will visit your blog site.You've seen views counters on different sites.Similarly, your blog can easily add views counter.Also, on a blog site, you can separate views, page views counter and post views counter.page views counter is a number of views on each pages blog.Also, post views counter is the number of views per post.Now you have some knowledge about this.


Creating your Firebase Account

You must first create a firebase account for this work.

1.First, go to https://firebase.google.com.
2.Then click GET START button.
3.Now click Add project.
4.You can then see a new window.Fill in the details and click CREATE PROJECT button.
Add post views counter to blogger
Creating your Firebase Account
5.Then go to Database section and click GET START button.
Add post views counter to blogger
Creating your Firebase Account
6.Now go to the RULES tab.You can see a code there.Then Copy and paste the following code instead and click PUBLISH button.There you can see a massage as "Your security rules are defined as public, anyone can read or write to your database".Dismiss it.
[{
 "rules": {
 ".read": true,
 ".write": true
  }
}]


7.Now click Setting icon and go to Project settings.Note the GENERAL tab of Project ID.
Add post views counter to blogger
Creating your Firebase Account
Now the firebase account settings have been completed.Next, add post views counter to blogger.Follow the steps below.

How to add post views counter to blogger

1.Go to Blogger » Template » Backup your Template » and Edit HTML.
2.Find (ctrl+f)  <data:post.body/>
2.Now Copy this code then paste it before <data:post.body/>
[<a expr:name='data:post.id'/> <i class='fa fa-eye'/> <span id='postviews'/> Views]
3.Now Find (ctrl+f) </body>
4.Copy the following code and paste it before </body>


[<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;);var blogStats = new Firebase(&quot;https://Project-ID.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.text(data.value);data.value++;if(window.location.pathname!=&#39;/&#39;){if(isnew)blogStats.set(data);elseblogStats.child(&#39;value&#39;).set(data.value);}});});</script>]


5.Now paste your Firebase Project ID instead of Project ID.


6.Finally save your Template

Note :- If post views are not working after the above step, .Copy the following code and paste it before </head>


[<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>]


Everything is right now.Next you can see the view counter in your blog post.So you know about How to add post views counter to blogger, Hope you like the post, don’t forget to share it with your friends and leave a comment below if you are facing any problem at any step in the method discussed above. Thank You.

最後に… このブログに興味を持っていただけた方は、 ぜひ 「Facebookページ に いいね!」または 「Twitter の フォロー」 お願いします!!