Use the document.referrer property and append that to the GET for each URL on the index page, for instance, change every link to use an onClick and pass a url to go to such as
<script>
function goto(url) {
url += "?referrer=" + escape(document.referrer);
window.location = url;
}
</script>
<a href="" onClick="Javascript: goto('/page2.php');">Go to page 2</a>
I'm not positive about the window.location but I think you'll get the gist of it from this.
Good luck