Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Track where users come from in PHP?

Tags:

php

tracking

Is it possible to find out where the users come from? For example, I give a client a banner, and the link. The client may put the banner/link to any website, lets say to a site called www.domain.com.

When the user click the banner, is it possible to know where he coming from(www.domain.com)?

like image 924
bbtang Avatar asked Oct 05 '09 10:10

bbtang


3 Answers

Have a look at the HTTP_REFERER variable. It will tell you what site the user was on before he came to your site.

like image 189
Marius Avatar answered Sep 28 '22 10:09

Marius


Yes. You give the client a unique URL, like www.yourdomain.com/in/e10c89ee4fec1a0983179c8231e30a45. Then, track these urls and accesses in a database.

The real problem is tracking unique visitors.

like image 32
gnud Avatar answered Sep 28 '22 10:09

gnud


See

 $_SERVER["HTTP_REFERER"]

Although that can't always be trusted as it's set by the client but you may not care in your case.

like image 43
smack0007 Avatar answered Sep 28 '22 10:09

smack0007