: Download tracking by IP Is it possible to track downloads from a website by IP address? Ideally, I would like to see a log file with possibly time stamps, occurrences, and who (IP address,
Is it possible to track downloads from a website by IP address?
Ideally, I would like to see a log file with possibly time stamps, occurrences, and who (IP address, and/or country of origin).
If someone could help point me in the right direction...
More posts by @Debbie626
2 Comments
Sorted by latest first Latest Oldest Best
If you are looking for something more simple and more specific. You could consider using AJAX to build your own log files system (or database) containing only the downloads you want to track.
The main reason for this is : because the webserver access logs contains eeeeeevery request made to your webserver. That means when a user only open one of your site's page, it can add an (extremely approximate) average of 30 to 70 lines in your log file. One for every little things used in the page (from HTML/CSS/JS files to every little beautiful 16x16px icons you've made with a lot of love using paint)
So if you want to track only specific files (like if you have a music download site and want to track only those music files), you could add an "onclick" event listener on your download links that DON'T point to the file, instead it fires an AJAX function that will run a server side script in witch you could save the infos about the download (ip address, timestamp, referrer, browser infos, etc...) :
Option 1 : in a log file if you want a simple chronological representation
Option 2 : in a database if you want to keep track of download counters more easily and in a more optimized structure as you won't duplicate data on the server.
After that "infos saving part", send back the URL of the file the user want to download to the browser and then, the browser gonna load this URL and the user gonna be able to download the file.
Using that method, you can be sure the download have been logged before the user download your file. It's better than sending the AJAX request simultaneously when a user click happen.
The only downside of this is : the fact that it's a "top layer" solution, if a user know the URL of your file and write it directly in his address bar, he will bypass your download counter. That wouldn't happen on a log files system based directly on the webserver (Apache or others).
I would like to see a log file
Your server access logs contain the information, you just need to extract it.
The access logs (text file) contain a record of every request made to your server. Included in the access log is the timestamp, the URL of the file requested, the IP address that requested the file and the status code.
To sum up all the times a particular IP address has requested a particular file you will need to traverse the log file. There are numerous tools around for processing access logs, however, you can write your own if it is a specific query you require.
Just to add, if you are doing this proactively then you would probably do this in your download script... log the File, IP address and increase a counter when the download is actioned.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.