Tracking your file downloads

Tracking is a king in mISV business.

When somebody downloads a file from your website you must log the event. Therefore, you must invoke a script (e.g. download.php) on your server that will write the info about the event in a file or database and then will redirect the visitor to the actual binary file.

In the same time, using script as a download link is not practical because many software archives do not allow links to php/pl/cgi pages, only to the exe or zip.

To overcome this you may use .htaccess file for redirection.

If you use http://www.site.com/download/abcmaker.zip as a public download link then the sample string for .htaccess can be:

Redirect /download/abcmaker.zip http://www.site.com/download/download.php?product=abcmaker

and the download.php must contain something like:

<?
...
//logging info to file or db
...
header("Location: /download/abcmaker_1421.zip"); //link to real file
?>

As you see this approach allows also to change the actual file name on the server while all incoming links may still point to http://www.site.com/download/abcmaker.zip

Share on Twitter Share on Tumblr Submit to StumbleUpon Save on Delicious Digg This Submit to reddit

6 Responses to "Tracking your file downloads"

  • Andrea Nagar says:
  • Dennis Crane says:
  • NirD says:
  • Dennis Crane says:
  • Andrea Nagar says:
  • Dennis Crane says:
Leave a Comment

Captcha
Enter the letters you see above.