New Module: FileField Track
I've often had clients request the ability to track downloads of files they upload to their site—0ne of even recently even said he'd like their email addresses. I thought this sounded reasonable enough—JW Player has done this for a long time, and I've happily complied—so I went module hunting and came up with Email Download.
This turned out to be a very well thought out module but it didn't plug into any existing file storage paradigm within Drupal (including the files database table). This solution didn't feel "Drupaly" (smurfy?) enough for me, plus I wanted something a little more flexible, so I made a super-thin module that accomplished the same task using FileField called FileField Track.
I wrote the module using Email Download as a starting point, but what I ended up with was different in almost every way. The solution I came up with is fairly thin, relying on file formatters to display alternate file links, so that all files end up with a URL like files/[fid]/[filename]. The inclusion of fid ensures that the URL is unique when file names dupicate across different directories.
Returning anonymous users are tracked using a cookie so that they only have to enter their email address once. A tracking interface shows email address and user account information for tracked files downloaded on the site.
I do see some problems right away. Some users might not like fid's being exposed (I can't really say I mind) while other people might not like the URL's I created for other reasons. Others may want to track information beyond someone's email address, but I say why not have the user just register for an account on the site, then? Speaking of which, maybe my links should optionally require an authenticated user, something you normally can't do with a public file system? And although the email request form is easy to modify with a form_alter, would it be better just to have it on a settings page?
Either way, hopefully people find some use in the module. Enjoy and let me know what you think!