Download counter : A Plugin for blogs!

Download counter for blogsThis is the first plugin of its kind created for websites which share downloadable resources. The plugin amazingly works with all major blogging platforms like wordpress and blogger blogs. It can even be used in static Sites or any CMS you 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 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!


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

Note: If you have already followed our first tutorial on firebase then ignore steps marked as (*)

1. Create your Firebase Account *

To store your data for 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 a 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:

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('') 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 src='' type='text/javascript'/>
$.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;; + 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;
   = id;
            isnew = true;
    $(e).click(function (e) {
        if (isnew) downloadStats.set(data);
        else downloadStats.child(&#39;value&#39;).set(data.value);

<!-- 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='' 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 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">

  • 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 Help?

I just hope this new plugin proves helpful for blogger users who are missing a database access. I am sure this plugin is the second best use of FireBase which is indeed a magic hub for developers. I would really appreciate you to use it for your projects. Please ask me any query you may have and feel free to share your precious views. Have fun buddies. Peace and blessings be upon you all always. :)


Note: All questions with links will be deleted no matter how important the question be. Avoid Spamming please.

Need Quick Help within 24 Hours? ASK NOW

If you don't want to get yourself into Serious Technical Trouble while editing your Blog Template then just sit back and relax and let us do the Job for you at a fairly reasonable cost. Submit your order details by Clicking Here »

37 comments : Post Yours! Read Comment Policy ▼
We have Zero Tolerance to Spam. Chessy Comments and Comments with 'Links' will be deleted immediately upon our review.

  1. I an Wating for this trick long time.
    Thanks for Share

  2. Nice Widget Mustafa Bro but Its not look like thats one which you applied on your download page. Mean you have applied another widget for download counter on your template page whenever some one download salahudin ayubi and some other things presents on your site which shows downloads counters. So how can we create thats widget because thats one seem professional. Thanks and hope for earlier reply.

  3. My Second question is little off topic bro dont mind. i am also confused about this issue.

    Mustafa bro why did you not insert meta description for each post inside post editor. we have analyze your current posts and some previous posts written by qasim and Nida sister. they are also doing that same and have not inserted meta description for post.

    As in your earlier post you have advised to write a meta description for each post so thats your post become very friendly for search bots. So why did you not write a meta description ?

  4. Nice share mustafa bro. You are awesome in this field. This is probably the reason why, We missed you a lot in your absense. I haven't tested it yet but will check it. Thanks again

  5. This is awesome! Thanks for the wonderful efforts MBT~!!

  6. You're awesome in widget creation. I love your work Mustaffa

  7. This is reaLly a good after exam gift from you. I will implement this as soon as possible on my blog.
    But I av a question. The files to be downloaded, will it be save in the dtabase we created in the firebase? Thanks for sharing though

  8. @Hafeez Khan
    I too have noticed many things that they advice us but don't apply them to their own blog. So its really indifferent.

  9. Note: All comments with links were deleted.


    Oh I am pleased it was what you were looking for ;)

    1. Buddy for that you will simply need to insert an image instead of the text Download Now!

    Use this code instead of that download now text:
    <img src="Download Image Button" />

    That simple :)

    2. Well buddy I strongly emphasize on meta description for individual posts and Qasim and nida strongly follow it. sometimes they forget to add it but I often emphaize on permalinks and search description.

    As far I am concerned since I am engaged with many tasks therefore I blog latenight and publish it as soon as I am done with it. don't often get time to set the permalinks and meta description because I carefully set my keywords in posts and titles. I blog using windows live writer where these options are not avaialable you will firts publish post as draft and then set them in blogger which takes time. so I avoid it. But that is my laziness which you must not follow! :)

    always welcomed ravi and please let me know once it works for you. You cna even customize the code and use download buttons as I guided hafeez :)

    My pleasure pal :)

    I love your kind feedback gagan. Thank you :)

    No the files can be uploaded anywhere. the firebase will aonly save the numeric count values. :)

    Thank you sangram :)

    @Dr Adil
    I guess there is a misconception here buddy which I clarified to hafeez. Please never feel hesitate in asking questions. that's the only way you will get proper guidance.
    Almost every thing that I follow for my blogs I share it with my readers. :)

  10. thank you very much Mohammad, good to see you back :D
    please make a customize css download and demo button, :)

  11. @Dr Adil RamzanYes brother but now i got the answer from Mustafa Bhai. He cleared me everything.

  12. Great but I think it is a bit to much for a non geeky guy like me,

    Muhammad Bhai when you are coming in Lahore for a seminar , I want to attend please tell kinldy. I am yoour huge fan ....

  13. Nice tutorial! I'll try this to my blog. :)

  14. Really nice one dude.
    you finally back!

  15. @Deddia Permana

    Oh sure I would love to share that! :)

    @Muhammad Basit
    Just tell your university or college to invite us and we will be right at your doors! :)

    Buddy normally city-wide requires time but I have no obligation if I receive a warm welcome from any interested university. :)

    Happy to see all my friends back :)

  16. @Mohammad Mustafa Ahmedzai

    thanks Mustafa bhai , I would be telling you soon , basically i am from a medical university, so any ideas how we can teach doctors about importance of blogging ;)

    i believe in getting fields interconnected

    i have sent you request on skype please add me, my skype ID


  17. 我們的uslagami不僅可以充分利用那些誰不知道我們。保存你的空閒時間,我們會為你做你的工作。 论文代写

  18. thank you, This is really helpful.
    How about counting image views?

  19. wow gr8 sharing...........keep it up.......

  20. i follow u step but doesn't work at my blog.. what happen.. sad~

    1. post the div codes as a html code, not as a text

  21. nice, now i can make- post view and download counter and site vies in just one post

  22. i have added every thing and ( DOWNLOAD NOW) button too..the button working but downloads counting is not increasing ...this problem i am facing please help me any one............>.

  23. Your blog is very good for healthcare information. I thanks to you for your blog ……….
    Thanking you

  24. Hello, i have a problem when adding this inside a table. My download link and preview link are inside the table and when i put the code in between download and preview the table will not align properly. Please help. Here's an example.

    <table align="center">
    <td><a class="download" href="#"></a></td><td><a class="livepreview" href="#"></a></td>

    So where do i put the download counter codes?

  25. Dear Mohammad, Can you please suggest how to integrate this code with new firebase account. Now above you suggest to add a new firebase account, but new code doesnt have this type of account.

  26. What kind of template you have used here??? can I get this kind of awesome theme???

    Clipping Path

  27. I can not put different links... It is always the same counter for each download... Thank you for your help. Can you tell me how to fix this problem? Thanks for Share... (Sorry for my english)

  28. WHat if need to add sumthing more to the text.
    For Ex. "8 Dowmloads"
    Now it only shows "8"
    I need to add that "download" Word
    Please help

  29. Hello, I want to statistics total downloads in month for my blog. How do it? This is mya blog: You go in my blog and comment

  30. Thank you!
    Could you tell please how to get more than one single link working with its own counter?
    Thank you!

  31. I had this working on a different template but now I can't get it to work on my new templet.