This plugin is a great addition to your blog by letting your readers see how frequent the post was viewed. This might not be as accurate as GA but this plugin works like a charm, thanks to Firebase for making this possible by hosting this for FREE.
The process will require some editing on the Template section so i suggest to back up the theme first , here's how to back up your blogger theme. If your done backing up your theme lets get started.
1. Create Firebase account
Go to: https://firebase.google.com/
Start by creating an account , once done you will be redirected to firebase dashboard
2. Create a Project
Go to: https://console.firebase.google.com/
Click "Add a project" to get started
3. Go to Database Tab and copy your Firebase database link
save it as we need it later
4. Now go to Blogger Dashboard > Theme > Edit HTML
Copy this code then paste it before <data:post.body/> so it appears above your every post and below post title.
<a expr:name='data:post.id'/> <i class='fa fa-eye'/> <span id='postviews'/> Views
to find </body> press (CTRL+F)
<script src='https://cdn.firebase.com/v0/firebase.js' type='text/javascript'/>
<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>
6. Change the highlighted Red with your Firebase database link you previously saved.
Save Your theme now and the plugin works great!
To check the demo , check the views counter above my post.
How do you like this plugin? Any issue with the installation? Do let me know by leaving a comment below.
No comments:
Post a Comment
● Be sure to click "Notify Me" below, to get notified for follow up response.
● Respect! Do not Spam/Flood, you will be banned if you do so.
● Admin will try to get back to you as soon as we possibly can.