Got Chance

simple way to track downloads

Simple way to Track Downloads

September 5, 2007 by Hari

A simple google search of “download tracker” yields 92,900,000 results. There are also a lot of nice download tracking script that i know. They all come in useful when you have a lot of files for download and you have your own download repository of large number of files, like on my other Free Webmaster Resources website (though i use a custom coded one there). But on this blog, i just have some 2-3 themes and 1 plugin for download as of now. So, a download tracker would simple be unnecessary. But, i would like to track how many times my file have been downloaded. I use a simple method here on my blog.

I have a PHP file with the following code :

<?php

$hits = file_get_contents("SOME-NAME.txt");

$hits = $hits + 1;

$handle = fopen("SOME-NAME.txt", "w");

fwrite($handle, $hits);

fclose($handle);

echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL=LINK-TO-ORIGINAL-ZIP-FILE" />';

?>

The SOME-NAME.txt is the text file to which the number of downloads is written. It needs to be CHMODed to 777. And initially, it should contain “0″ as the file content. The LINK-TO-ORIGINAL-ZIP-FILE is the link to the file that needs to be downloaded. It can be any type, not necessarily be a Zip file.

I currently use this method for all my downloads on this blog. For eg, Got Banners can be downloaded from Here. The tracking is done on this TEXT File. Now, i hope that helped some of you.

If you’re new here, you may want to subscribe to our RSS feed. Thanks.

Posted in Programming, Web Development.









30 Responses to “Simple way to Track Downloads”

Trackback URL
Feed for this entry

 

Nice tip . Will definately help me sometime .

Madhur Kapoor wrote on September 19th, 2007 at 4:10 pm

 

Nice Tip , will definately come in handy sometime .

Madhur Kapoor wrote on September 19th, 2007 at 4:14 pm

 

Thanks. This could definitely be very useful in the future.

Steven Snell wrote on September 19th, 2007 at 10:19 pm

 

Cool ! Thanks for your comments

Hari wrote on September 20th, 2007 at 1:48 am

 

PHP…. just thinking about it sends shivers down my spine… but its easy when someone gives you the code. Thanks.

MDB wrote on September 20th, 2007 at 12:57 pm

 

Yep, its has once upon a time sent shivers down my spine too. But, i got used to PHP and became a 50% expert in it.

Thanks to SimpleMachines forum software. It gave me experience. Thanks to PHP Freaks and their forum members. Without them i could not have imagined about PHP. Clever Tutorials and Kontactr and another video indexing site – all these i made only with the help of PHP Freaks.

Hari wrote on September 20th, 2007 at 1:16 pm

 

Thanks for the code, and also for the recommendation for the PHP freaks forum!

JoLynn Braley wrote on September 21st, 2007 at 5:08 am

 

lo

film izle wrote on April 19th, 2008 at 2:26 pm

 

ultras

beşiktaş wrote on April 19th, 2008 at 2:27 pm

 

earlyn

hit sihirbazı wrote on April 19th, 2008 at 2:27 pm

 

opel

hit oranı wrote on April 19th, 2008 at 2:28 pm

 

jackass

ankara evden eve wrote on April 19th, 2008 at 2:28 pm

 

Man this is awesome.

Simple and useful at the same time!

Thumbs UP!

Roboblob wrote on April 19th, 2008 at 4:12 pm

 

To my mind it must be mentioned about such parameters as “safe_mode”, “safe_mode_gid”, “safe_mode_include_gid”, “open_basedir”. These parameters are set in “php.ini” and they limit of using “fopen” and “fwrite”.

sim wrote on May 4th, 2008 at 3:18 pm

 

You can use simple Mysql queries as well to store the counter in database instead of a text file

George Lindemann Jr wrote on May 24th, 2008 at 2:28 pm

 

Yes that is possible.. Just that this method doesn’t use a database and so it is simpler…

Hari wrote on May 29th, 2008 at 3:49 am

 

Thanks for the code, and also for the recommendation for the PHP freaks forum!

يورو 2008 wrote on May 29th, 2008 at 1:41 pm

Trackbacks/Pingbacks
  1. iPhone Accessories- Complete Application downloads | forextradingcourse.org
    on September 5th, 2007 at 2:32 pm
  2. “How-To” Group Writing Project: Final Entries List | bluejar.com – the webmasters guide to the galaxy
    on September 19th, 2007 at 7:25 am
  3. Untitled | felix ker’s blog
    on September 19th, 2007 at 12:23 pm
  4. Bluejar’s Group Writing Project : My picks
    on September 20th, 2007 at 2:23 pm
  5. BlueJar Contest: Voting My Favourites
    on September 20th, 2007 at 3:28 pm
  6. Weekly Links << Vandelay Website Design
    on September 20th, 2007 at 11:06 pm
  7.   blueJAR.com “How To” Group Writing Contest – My Top Picks by Internet Marketing Mind
    on September 23rd, 2007 at 3:02 pm
  8. » Why You MUST Write Better Headlines J-NE.WS: The “Social Viral Marketing” Weblog: Using Social Media to drive Viral Marketing
    on September 24th, 2007 at 1:48 pm
  9. Bluejar Group Writing Project: My Picks
    on September 25th, 2007 at 6:47 am
  10. Bluejar Group Writing Project: My Picks – Contest Beat
    on September 25th, 2007 at 8:12 am
  11. Roberta Ferguson » Blog Archive » BlueJar Group Writing Project – My picks
    on September 25th, 2007 at 2:11 pm
  12. BlueJAR How To Group Writing Contest | Karol Krizka
    on September 28th, 2007 at 3:45 pm
  13. 150+ Tips and Tricks to Make Money Online | Anthony Jude Lawrence Dot Com
    on September 29th, 2007 at 7:22 pm

Leave a Reply