WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have multiple media files in my WordPress Media Library. Icons, Images, PDF's and the like. I would like to have a stat counter, that gives me a statistic of the downloads/hits of those files, individually.

I already use WP SlimStat to track page view, and I am quite happy with it. However, I have not found a possibility to track those media files.

How can I do this?

share|improve this question
up vote 4 down vote accepted

You could use Google Analytics for WordPress. Here's an excerpt from their FAQ on how you could set it to track certain file types:

How can I track downloads? Check the box for "Track outbound clicks & downloads", after that, make sure the file types you want to track are listed in the box of extensions to track as downloads. You’ll find this input field under "Advanced".

share|improve this answer
    
Thanks, this answers the question. To me however, Google Analystcs is not an option, because it requires the adoption of Google's privacy policy. – Marcel Mar 24 '14 at 7:00

Using Google Analytics will only collect clicks on your web pages, it will not count hits from external sites, RSS feeds, apps, etc. For this you'll need to utilise your server log files.

AWStats is good for this but it is overkill for a single file - you'd need to log in, set the timeframe to a large span, then browse for your file... it would be much easier if the WP files admin could check the server logs for definitive all-time hits for each file, but I am yet to find a plugin for this.

share|improve this answer
1  
I actually use AWStats for now to some degree, but I find it clumsy and inflexible. – Marcel Mar 24 '14 at 7:01

If you need to track single file, and you have the URL of the file, and you have the access.log file set up right, then you can just use grep Linux command.

grep "/downloads/my-file-name.media" /var/log/access.log

To get the number of requests

grep -c "/downloads/my-file-name.media" /var/log/access.log or

grep "/downloads/my-file-name.media" /var/log/access.log | wc -l

share|improve this answer
    
I'm not sure this answer will be useful for the original poster or for others coming across this post - the implied premise of the question is being able to track these downloads through the WP interface. Many WP users will have no idea how to run shell commands - or may not even have shell access. – Tim Malone Apr 15 at 10:30
2  
Sure, I provided this just for the record. Some users of this forum may find this OK. BTW, I fully agree with your feedback. – prosti Apr 15 at 10:35

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.