views:

63

answers:

5

I have an image that send to affiliate for advertising. so, how can I find it out from my server the number of times that image been downloaded? does server log keep track of image upload count?

---- Addition ---- Thanks for the reply.. few more questions

because I want to do ads rotation, and tracking IP address, etc. so, i think I should do it by making a dynamic page (php) and return the proper images, right?

In this case, is there anyway that I can send that information to Google Analytics from the server? I know I can do it in javascript. but now, since the PHP should just return the images file. so what I should do? :)

A: 

HTTP log should have a GET for every time that image was accessed.

TMN
+1  A: 

It depends on a server and how you download the image.

1) Static image (e.g. URL points to actual image file): Most servers (e.g. Apache) store each URL served (including the GET request for the URL for the image) in access log. There are a host of solutions for slicing and dicing access logs from web servers (especially Apache) and obtaining all sorts of statistics including count of accesses.

2) Another approach for fancier stuff is to serve the image by linking to a dynamic page which does some sort of computation (from simple counter increment to some fancy statistics collection) and responds with HTTP REDIRECT to a real image.

DVK
A: 

You should be able to configure your server to log each download. Then, you can just count the number of times the image appears in the log file.

Zian Choy
A: 

Use Galvanize a PHP class for GA that'll allow you to make trackPageView (for a virtual page representing your download, like the file's url) from PHP.

Erik Vold
+1  A: 

Well This can be done irrespective of your web Server or Language / Platform.

Assuming the File is Physically stored in a Certain Directory. Write a program that somehow gets to know which file has to be downloaded. Through GET/POST parameters. There can be even more ways. then point that particullar file physically.

fopen that file
  read through it byte by byte
  print them
fclose
store/increment/updatethe download counter in database/flatfile

and in the database you may keep the record as md5checksum -> downloadCounter