Jim_Bo
Jim_Bo

Reputation: 317

Track image impressions/statistics in log file

Tried to find answer here but, no luck so, here goes;

I would like the ability to log a specific images "hits" or even just a log file that reports all image loads of all images (w/individual stats) that reside in a specific folder.

I DO NOT want to serve images on a remote server via a script e.g. <img src=image.pl?thisone> . I just want the ability to use a standard image tag.

I even thought of using htaccess RewriteRule with ^<img but, beyond my understanding / experience with htaccess. I just use it to conceal my sites structure a little and some level of protection. (thanks to ultimate htaccess).

I have torn through apps like awstats (which I actually like) and found tons of bulkware "solutions" that offer far too much. I just cannot find a snippet containing a clue.

I just need to log how many times that image was loaded into someones browser. If I can get a few more details that would be fine but, really just need an image impression hit counter.

This would allow me to make a quick stats page for a local artist friend I am making a simple site for. He could then just hit a stats page and check the stats on his images views. Tracking clicks are no problem (the img is wrapped in a link to his site).

I searched cpan for a module to install to no avail. Obviously PERL is my pref here but, any solution that gets me going is appreciated. I spent all day trying to figure this one out.

Thanks in advance..

Upvotes: 1

Views: 1131

Answers (1)

Sabeen Malik
Sabeen Malik

Reputation: 10880

you can use htaccess to send *.jpg etc to a script , possible php or perl, that file would log the hit to the DB and then return the image.

something like this

Options +FollowSymlinks
RewriteEngine on

RewriteRule ^(.*).jpg$ image.php?name=$1 [L,NC]

Upvotes: 2

Related Questions