if you have php and you have a php script and you want to know where your visitors are coming from you can actually use to find out who is sending you traffic to your site, you can use it with a database and you can keep track like a counter of where how are your referrers, you will get the domain name and the url of where the hits are coming from with

try it.