Question

I'm trying to track when a user downloads a .zip file from my Rails site. The file is hosted by S3/Cloudfront. If the HTML is something like:

<a href="http://something.cloudfront.net/path/to/file.zip">Download File</a>

I could attach a JQuery event that will send a GET request to my server that will increment the downloads column in my database. However, if the user goes to the URL directly, the download will occur but it will not be tracked.

Is there a solution?

Was it helpful?

Solution 2

Yudong's answer is the only one which would work by just providing a download link, but Amazon states that they log on a "best effort" basis and it's by no means accurate accounting. I think the simplest way would do a redirect and count the redirects and the most accurate would be to stream the zip file yourself through your server (would not really make a huge difference if hosted on Amazon as well unless you have a lot of traffic and huge files). Another way would be to use a CDN which gives you accurate access logs. Your Jquery idea is as good as the redirect.

OTHER TIPS

If you don't mind a bit delay of the tracking result, the most accurate tracking is by using access logs of CloudFront. http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/AccessLogs.html

You will be able to find out the exact request history of your items by parsing the access logs.

Parsing those cloud front logs in not easy (you will have to have an EMR periodic job and post the results to a DB etc - some work involved).

If you dont might paying a little, you can use these services: https://qloudstat.com/welcome http://www.s3stat.com/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top