Iklan Anda
Ever wonder how many people visit your website? If you're an administrator of a website then sure you are. Post view counter or tracker is a widget or plugin that counts (and also displays) how many times a posts has been viewed. This helps blog author (and also readers) to know how much popular that post is. But to create this type of plugin, you have to know php, database, javascript etc, which is not so easy. However I've found a website, Firebase that also does the same job. You can create free accounts at Firebase and you can use their scripts to install post view counter in your blog. It doesn't matter which blogging platform you're using because Firebase works with all major blogging platforms and websites.
Signup for your free account. Follow the steps carefully given at Firebase to activate your account.
Firebase offers you to create 10 unique databases. In our case, only one database is required. Create one to store your post view stats. Give your database a unique name
Follow steps:
Step #1: Create Your Firebase Account
Signup for your free account. Follow the steps carefully given at Firebase to activate your account.
Step #2: Create Your Database at Firebase
:
Firebase offers you to create 10 unique databases. In our case, only one database is required. Create one to store your post view stats. Give your database a unique name
Step #3: Install Post View Counter Plugin
- Sign in to Blogger account and go to Blogger dashboard.
- Click the arrow adjacent to 'Go to post list' icon and select 'Template' from the drop down menu. Alternately you can click 'Template' from left navigation menu if you're already within your blog.
- Click 'Edit HTML'.
<head>
and paste (Ctrl+V) the following line just after <head>
. <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
- Search for (Ctrl+F)
</head>
and paste (Ctrl+V) the following code before</head>
.
<script src='https://cdn.firebase.com/js/client/2.2.1/firebase.js' type='text/javascript'></script> <script type="text/javascript"> //<![CDATA[ $(function() { $('.post').each(function() { var fdb = '--YOUR DATABASE--'; var $this = $(this), $title = $this.find('.post-title').text().trim(); var dataRef = new Firebase(fdb + $title); dataRef.transaction(function(curr){ if (window.location.pathname!='/') { return (curr||0) + 1; } else { return (curr||0); } }, function(e,c,s){ $this.find('.blr-view-counter>span').removeClass('blr-view-loading').empty().html(s.val()); }); }); }); //]]> </script>
Replace
--YOUR DATABASE--
text with your actual database you've created in step #2 but don't remove quotation around your database.- Search for (Ctrl+F)
</b:skin>
, copy (Ctrl+C) the following code and paste it (Ctrl+V) before</b:skin>
.
/* --- Post View Counter by prio-soft --- */ .blr-view-counter { margin: 0 10px 10px 10px; padding: 8px 5px 8px 35px; float: right; text-align: center; background: #fff url('http://3.bp.blogspot.com/-L45u_pdvSsg/Umz1WLZEUSI/AAAAAAAAC2A/96QhAnVyq-I/s1600/post-views.png') 3px 50% no-repeat; display: inline-block; color: #444; } .blr-view-loading { background: url('http://3.bp.blogspot.com/-EERf4K_hjBg/UmzBza69BtI/AAAAAAAAC1Q/67AexTAsKJU/s1600/spinner.gif') 50% 50% no-repeat; display: inline-block; width: 30px; height: 18px; margin: 0 0 -3px 0; }
- Search for (Ctrl+F)
post-header
. You'll find the a code similar to the following one.
<div class='post-header-line-1'/> </div>
- Replace
<div class='post-header-line-1'/>
with the following code.
<div class='post-header-line-1'>
<div class='blr-view-counter'>Post Views: <span class='blr-view-loading'/></div>
</div>
Enjoy !
I tried my best to keep things simple as possible. Any type of question related to this will be appreciated.
Happy Blogging.
Iklan Anda
Baca juga:
Tags:
#Blogger