Sunday, 28 July 2013

New Plugin for blogger 'Download Counter'

It is the first plugin of kind created for websites which share downloadable resources. The plugin will amazingly works with all major blogging platforms like wordpress and bloggerblogs. It can even be used in static Sites or any CMS you Firebase system that allows developers to create dynamic and data-driven tools without worrying about backend development. You do not need to worry about server code or managing databases, firebase does it all for free. All you need is to code some delicious scripts that does half the work.  This plugin is a custom alternative to Dstats download tracking service. Lets add this amazing tool to your blogger blogs!!!
may be using. This tool will count and display download stats whenever a visitor downloads a resource form your site. The data is stored at your firebase free account. Luckily we are amongst very few who have started developing tools using the newly introduced 

The following link will take you to our first plugin created with the Firebase.

1. Create your Firebase Account * :

To store your data for the downloads, you will first sign up for a free account at Firebase.
Fill up the easy steps sensibly and then once your account has been activated, you must create your first Firebase database as guided below in step#2.

2. Create  Firebase Database

Previously you could only create 2 firebases but now you can create a total 5! So create one for your download stats data
  1. Towards the bottom right side of your account, you will find the following submit box.
create firebase
  2.  Give your firebase a short name. In my case I named it mbtblogstats. This name will be used as your unique Identification.
  3.   Hit create and note down your firebase URL because we would need it later in this tutorial.

Installing Download Counter Plugin's:

The steps below are for blogspot blogs. Wordpress users may simply note down the method and apply accordingly on their WP powered blogs.
  1. Go To Blogger > Template
  2. Backup your template
  3. Click Edit HTML
  4. *Search for </b:skin>.  Click the black arrow to expand the code.
compressed blogger stylesheet
   5.  Paste the following Styles just above </b:skin>
/*----- download counter by MBT-----*/
.mbtloading {
background: url('https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEigVAwBMekw6iwIBUlwxFv8jDhtV20Chut96mf2cYJ23EZVQEYG2EgZJJJbNV1FG_6b0zTtsAV0Mut300UGOZcd7t4m1loP9w_HqIWhBG9X-AEOnnWK5TIKdtu62luOBdFd1ASywaDo0Rad/s320/mbtloading.gif') no-repeat left center;
width: 16px;
height: 16px;
}
.blog-stats {
color: #289728;
font: bold italic 18px georgia, arial;
float: right;
}

You can easily change the color and size of the Numeric Text count by editing   #289728
Tip: Use our color generator Tool to pick a color of your choice
6. Now search </body> and just above it paste the following script:
<!-- Download Counter by MBT starts-->

<script type='text/javascript'>
    window.setTimeout(function() {
        document.body.className = document.body.className.replace(&#39;loading&#39;, &#39;&#39;);
      }, 10);
  </script>
<script src='https://cdn.firebase.com/v0/firebase.js' type='text/javascript'/>
<script>
$.each($(&#39;[data-download-count=true]&#39;), function (i, e) {
    var elem = $(e).parent().find(&#39;#download-count&#39;).addClass(&#39;mbtloading&#39;);
    var id = $(e).closest(&#39;.post-body&#39;).siblings(&#39;a[name]&#39;).attr(&#39;name&#39;) + &quot;-&quot; + $(e).attr(&#39;id&#39;);
                          var downloadStats = new Firebase(&quot;https://mbtblogstats.firebaseio.com/downloads/id/&quot; + id);
    var data = {}, isnew = false;
    downloadStats.once(&#39;value&#39;, function (snapshot) {
        data = snapshot.val();
        if (data == null) {
            data = {};
            data.value = 0;
            data.url = window.location.href;
            data.id = id;
            isnew = true;
        }
        elem.removeClass(&#39;mbtloading&#39;).text(data.value);
    });
    $(e).click(function (e) {
        data.value++;
        if (isnew) downloadStats.set(data);
        else downloadStats.child(&#39;value&#39;).set(data.value);
    });
});
//<![CDATA[
$(document).ready(function () {
  //checks if the number of posts on this page are more than one then return.
  if($('.post-outer').length > 1)
  return;
  //selects the element to be made sticky.
  var stickElement = $('.date-header'),
    //selects the element which would trigger the sticky elem to go away
    hideTrigger = $('#comments'),
    //class name to be added (it should match the class in CSS)
    fixed = "fixed",
    top = stickElement.offset().top;
  $(window).scroll(function (event) {
    var y = $(this).scrollTop();
  var maxY = hideTrigger.offset().top;
    if (y >= top && y < maxY) {
      stickElement.addClass(fixed);
    } else {
      stickElement.removeClass(fixed);
    }
  });
});
//]]>
</script>
<!-- Download Counter by MBT Ends-->

Replace mbtblogstats with your Firebase name that you created in step#2.
     7.  Now search for <head>   and paste the following JQuery library just below<head>
<script src='http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js' type='text/javascript'></script>

You may not add the jquery code if you have already linked to Jquery library in your blog.
      8.   Save your blog and you are all done with coding!

Displaying Download stats in the Posts

Now whenever you wish to display download stats for a particular file. Simple link to your file using the code below:
<div style="width:120px;">
<a data-download-count="true" href="#">Download Now!</a>
<div class="blog-stats" id="download-count">
</div>
</div>
  • Replace the # sign with your File link.
  • You can write anything instead of Download Now! If your link is bigger in length then increase the width of the counter so that it shows the count in alignment.

Need any help feel free to contact us.. !

1 Responses to “New Plugin for blogger 'Download Counter'”

House Of Psalmist said...
25 August 2019 at 00:46

I've followed the procedures exactly but the counter is not showing


Post a Comment