Log in

View Full Version : Link tracker with PHP



auriaks
02-17-2010, 01:52 PM
Hi,

Most of you know Google Adsense.. So I want to get information which users uses that links and how many times.

It is possible to track that? (if user push google-adsense link in my webpage I will get info somehow. Who, which link, when, how many times)

Thanks.

auriaks
02-17-2010, 04:08 PM
Is it even possible to do? :)

Schmoopy
02-17-2010, 04:24 PM
I did this a while back, and I may still have the files at home. I'll have a look later for you. Yes, it is possible, but I wouldn't want to write it from scratch. At it's core, it's a simple concept:

1. When - Simply use date() in PHP
2. Who - if you have members setup, then this is easy ($_SESSION['user_name']), otherwise you won't know, you could get IP though.

3. The link - easy too, just take whatever is being clicked on from the href="" attribute. Or you could also perhaps use $_SERVER['HTTP_REFERER'] if you want to use a separate file.

4. How many times - Check the database, if a record matching that link is in there already, increment the "views" or "hits" field, otherwise create a new record.

auriaks
02-17-2010, 04:39 PM
That would be really good. I would be even happy if I could save nick's who entered the links.