Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I track file downloads

I have a website that plays mp3s in a flash player. If a user clicks 'play' the flash player automatically downloads an mp3 and starts playing it.

Is there an easy way to track how many times a particular song clip (or any binary file) has been downloaded?


Is the play link a link to the actual mp3 file or to some javascript code that pops up a player?

If the latter, you can easily add your own logging code in there to track the number of hits to it.

If the former, you'll need something that can track the web server log itself and make that distinction. My hosting plan comes with Webalizer, which does this nicely.

It's a javascript code so that answers that.

However, it would be nice to know how to track downloads using the other method (without switching hosts).

like image 853
Grant Avatar asked Aug 01 '08 17:08

Grant


People also ask

How do I track downloaded files?

To view file downloads, log in to your Google Analytics account and select the website where you'd like to track file downloads. If you've enabled downloads tracking as page views, you can find out the downloads report in the All Pages report along with other blog posts and pages.

What can be used to keep track of files we download?

MemberPress has an addon called MemberPress Downloads that lets you track each files that your members download. It also gives you advanced access control, letting you upload multiple files and tag, categorize, and list them easily. Aside from files, you can also protect other content on your site as well.

Can Google Analytics track file downloads?

Once the plugin is installed, PDF downloads will be tracked as events in your Google Analytics dashboard. The good news with some of these plugins is that you don't need to do any more work than download and install it. They'll do all the hard work to ensure you can track each and every download in Google Analytics.

How do I track downloads on Google Drive?

Yes. First click on the "Downloads" tab on the project page. The total number of downloads for a particular file can be found in the "DownloadCount" column.


1 Answers

The funny thing is I wrote a php media gallery for all my musics 2 days ago. I had a similar problem. I'm using http://musicplayer.sourceforge.net/ for the player. And the playlist is built via php. All music requests go to a script called xfer.php?file=WHATEVER

$filename = base64_url_decode($_REQUEST['file']); header("Cache-Control: public"); header('Content-disposition: attachment; filename='.basename($filename)); header("Content-Transfer-Encoding: binary"); header('Content-Length: '. filesize($filename));  //  Put either file counting code here, either a db or static files // readfile($filename);  //and spit the user the file  function base64_url_decode($input) {     return base64_decode(strtr($input, '-_,', '+/=')); } 

And when you call files use something like:

function base64_url_encode($input) {      return strtr(base64_encode($input), '+/=', '-_,'); } 

http://us.php.net/manual/en/function.base64-encode.php

If you are using some JavaScript or a flash player (JW player for example) that requires the actual link of an mp3 file or whatever, you can append the text "&type=.mp3" so the final link becomes something like: "www.example.com/xfer.php?file=34842ffjfjxfh&type=.mp3". That way it looks like it ends with an mp3 extension without affecting the file link.

like image 104
w-ll Avatar answered Oct 08 '22 05:10

w-ll