How do I track file downloads

2019-01-17 02:03发布

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 javascript code, so that answers that.

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

8条回答
smile是对你的礼貌
2楼-- · 2019-01-17 02:36

Use bash:

grep mp3 /var/log/httpd/access_log | wc
查看更多
SAY GOODBYE
3楼-- · 2019-01-17 02:39

The problem I had with things like AWStats / reading through web server logs is that large downloads can often be split in data chunks within the logs. This makes reconciling the exact number of downloads quite hard.

I'd suggest the Google Analytics Event Tracking, as this will register once per click on a download link.

查看更多
冷血范
4楼-- · 2019-01-17 02:41

Use your httpd log files. Install http://awstats.sourceforge.net/

查看更多
forever°为你锁心
5楼-- · 2019-01-17 02:43

You could even set up an Apache .htaccess directive that converts *.mp3 requests into the querystring dubayou is working with. It might be an elegant way to keep the direct request and still be able to slipstream log function into the response.

查看更多
时光不老,我们不散
6楼-- · 2019-01-17 02:54

Is there a database for your music library? If there is any server code that runs when downloading the mp3 then you can add extra code there to increment the play count. You could also have javascript make a second request to increment the play count, but this could lead to people/robots falsely incrementing counts.

I used to work for an internet-radio site and we used separate tables to track the time every song was played. Our streams were powered by a perl script running icecast, so we triggered a database request every time a new track started playing. Then to compute the play count we would run a query to count how many times a song's id was in the play log.

查看更多
一夜七次
7楼-- · 2019-01-17 02:58

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.

查看更多
登录 后发表回答