Skip to main content

What's the best way to track file downloads (stats)?

General • Asked by Anthony M Pizzurro

Thanks to the videos here, I've implemented file upload with Shrine in my app. They are audio files, stored on s3, and made available to the public.

I'd like to track the downloads and provide my users with some basic statistics. I don't see any out of the box solutions/gems that can get me close.

I've considred:

  • Parsing s3 bucket logs and creating a record in my app's DB
  • Setting up a url redirect, grabbing the request data, and creating a record in my app's DB

Is one of these methods better than the other? Is there a better option?

Thanks!
-Anthony


  • I think parsing the S3 bucket logs could work but it may be hard for you to tell who did what if you want to track who did what.
  • I have done the redirect version of this before for http://feedforward.io/ and it works pretty well. You link to /whatever/1/download and then record the download and then redirect the user to the actual download url. Works pretty well.
  • Another thing you could do is use a JS tracker like Ahoy or Mixpanel, etc where you track it with an AJAX request when the user clicks the download link. This means you don't have to have anything special going on in your app and you can use third party analytics tools like Mixpanel really easily.

I'd probably go with one of the latter options for simplicity.


Login or Create An Account to join the conversation.

Subscribe to the newsletter

Join 22,346+ developers who get early access to new screencasts, articles, guides, updates, and more.

    By clicking this button, you agree to the GoRails Terms of Service and Privacy Policy.

    More of a social being? We're also on Twitter and YouTube.