I am working on a website statistics engine for a class. The idea being that you can simply embed a little code in your web page which will call the stats website on every p
$_SERVER['HTTP_REFERER']
will get you the referring page.
In addition to $_SERVER['HTTP_REFERER']
since there may be large chunks of the URI you wish to ignore, you can just pass the page name as a request param to the called script.
I.E. on the page with stats tracking you request
URL/stats_tracker.php?page=checkout
on the stats tracker page you just look for
$_REQUEST['page'];
This can be cleaner than looking at the whole URL.