Reputation: 827
I am hosting several software packages which are required to be linked on several forums.
I currently am hosting the packages by directly linking to the files. The problem I have is people share these links, making it hard to track who downloads and from where without reading logs.
I do not use google analytics on this particular site and am aware of previous answers which have mentioned eventTrackerOverview / eventTrackerGuide which are great Google features, however I would like to do a simular thing only using PHP.
The only information I care about is
I am very open to creating unique links to each package, possibly doing some sort of redirect to deliver the package download. Another idea I am exploring is parsing the logs to find this information, which would be a different way to go about it.
Upvotes: 1
Views: 192
Reputation: 90776
I would make all the download links go through a simple PHP file that 1) collect the HTTP referrer 2) collect the file that's being downloaded. Then redirect to the location of the physical file. I've got something like this working on my server:
$fileId = $_GET['file_id'];
// Get physical file URL based on file ID
$fileUrl = ....
// Here save $_SERVER['HTTP_REFERER'] and file ID to some database
// Finally, redirect to physical file:
header("HTTP/1.1 302 Found");
header("Location: " . $fileUrl);
Upvotes: 4