I've been looking for some articles about adding post views to bloggers and I find an easy way to do it. Example of the view counter on the blog as below or on the blog that I use this
Counter view is to display the number of views on articles. And counter view certainly has the benefit of making visitors know which articles are most viewed so they know that the article is really useful.
The following step by step in creating a view counter on blogger:
1.Go To HTML>>Template>>Edit HTML
2.Find .showAuthor in html or you can find it with CTRL+F and write . .showAuthor
<a expr:name='data:post.id'/> <i class='fa fa-eye'/> <span id='postviews'/> Views
</Body><script src='https://cdn.firebase.com/v0/firebase.js' type='text/javascript'></script>
<script>
$.each($("a[name]"), function(i, e) {
var elem = $(e).parent().find("#postviews");
var blogStats = new Firebase("https://YOUR-APP-NAME.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.text(data.value);
data.value++;
if(window.location.pathname!="/")
{
if(isnew)
blogStats.set(data);
else
blogStats.child("value").set(data.value);
}
});
});
</script>
Counter view is to display the number of views on articles. And counter view certainly has the benefit of making visitors know which articles are most viewed so they know that the article is really useful.
The following step by step in creating a view counter on blogger:
1.Go To HTML>>Template>>Edit HTML
2.Find .showAuthor in html or you can find it with CTRL+F and write . .showAuthor
3.paste the script above all .ShowAuthor as shown below
4.Paste This Script above </Body> in your html as shown below
<script>
$.each($("a[name]"), function(i, e) {
var elem = $(e).parent().find("#postviews");
var blogStats = new Firebase("https://YOUR-APP-NAME.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.text(data.value);
data.value++;
if(window.location.pathname!="/")
{
if(isnew)
blogStats.set(data);
else
blogStats.child("value").set(data.value);
}
});
});
</script>
5.Save the script and then you can see the result
Njir copas
ReplyDeleteGreat for guide
ReplyDeletedoesnt work at all
ReplyDeletetry it again.
DeleteIts not working bro, seems blogger updated their variables. Check the source code of my blog and tell me where to paste it 9jaedublog.com.ng
ReplyDeleteworking fine, thanks
ReplyDeleteRegards,
AJAY KUMAR
Thanks, that's working..
ReplyDeleteThank you dear
ReplyDeleteThank you to share the great post
ReplyDeleteno working in new blogger templates layout version 3 such as: contempo, soho, emporio and Notable
I try this, but its not working
ReplyDeleteNice BLOGS
ReplyDeleteNo work
ReplyDeleteAt OXO Packaging, we are always busy in designing pop up displayed and uniquely shaped bath so Counter Display Boxes that exhibit countless design features and will also lure clients, making them brand loyal towards your products.
ReplyDeleteerror at firebase notice
ReplyDeleteHi, I followed the instructions. It turns up in the admin panel. The word views shows under the posts and pages but not any hits. Am I missing something? I put my firebase url in as well. Best wishes
ReplyDeleteAwesome write up.. Visit NairaTechs Blog for all network free browsing cheats, apps and apps solutions, blogging tips and more👇
ReplyDeleteNaira Techs
Not working
ReplyDeletehttps://knoworld18.blogspot.com/