Our Technical Team made some research and found out that many blogger hosting their blog/blogs on blogspot, would have loved to enable the post and page view counts feature on their blog but unfortunately could not do so because blogger blogs do not support such feature at this time. Well WordPress does, but many new blogger cannot afford WordPress as it is very expensive compared to blogger but has so many features that bloggers does not, one of those feature is post and page view count, however, we have sort out something’s and find a solution to this manually pending the time blogger enable this feature in the future, that’s if they are thinking of doing so anyway. So let’s get to business, the process isn’t long but you’ll need to follow it accordingly.

Here is how to go about it

First of all, before you begin this process , you’ll need to back up your theme, so in case you make mistake while editing the HTML source of your website as we are going to use some little coding here

Go to your blogger dashboard
Click on theme
Click on Backup/Restore at the top left corner
Click download theme.
Then your browser will automatically initiate the download, the theme file would be in XML. Save that just in case

To enable view counts, you’d need to open a firebase account [firebase is owned by Google, mostly for documents, websites or software analytic] click here to create the account

Once you’ve created your account Google will redirect you to the firebase dashboard where you’ll create your first project.

Click on Add a project
Then name that project whatever you want or have in mind

Then go to database tab, you’ll a link, copy it and save it as we are going to need it later

Now go back to your blogger dashboard, click on theme and click on Edit HTML wait for the codes to load


Now locate
<data:post.body/>

and paste the below codes before

<a expr:name=’data:post.id’/> <i class=’fa fa-eye’/> <span id=’postviews’/> Views

Then add the below Java script before the </body> to find body press Ctrl F then type </body> when you find the body tag, then past the below code


<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://YOUR-APP-NAME.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);
else
blogStats.child(&#39;value&#39;).set(data.value);
}
});
});
</script>

Then look at the segment with RED HIGHLIGHT that’s says YOUR-APP-NAME, kindly erase it and put the name of your firebase project you created in the beginning, in my own case, my project name for fire base is mypostviewcount then I just replaced it with YOUR-APP-NAME.

Hit, save theme, gbam you’re good to go. You can see a demo of this at the top of the page your reading now

Please note that sometimes you might see the (views) inscription alone but the count is empty, this is because google automatically set your fire base project to private so you have to make it public so that the views can start counting, kindly go back to your fire base
Click on rules

Then replace whatever code you see there wi with this

// These rules give anyone, even people who are not users of your app,
// read and write access to your database
{
“rules”: {
“.read”: true,
“.write”: true
}
}

Hit publish, in 10 minutes you should start seeing post view counts on your posts, if you have issues with the work round , contact us using the form below, we’d help you with workround

[bestwebsoft_contact_form]