-1

I currently have a tracking system that logs referers for all tracked actions. To achieve this I'm using $_SERVER['HTTP_REFERER'] in PHP.

My issue is that sometimes, the above returns nothing. When it works, it returns the last referer, which seems to be completely WAI.

When I double-track using google analytics, GA returns the very site from which the request originated.

I'd like to know how I can achieve that myself, or if it is even possible?

Esoteric Screen Name
  • 6,082
  • 4
  • 29
  • 38
user1159791
  • 505
  • 1
  • 7
  • 15
  • Referer is only set if they got to the page by clicking on a link. If they type the URL into the browser address bar, there's no referer. And if they get there by Javascript doing `document.location.href=...`, browsers differ in whether they set referer. Finally, anonymizing proxies can be configured to filter out referers. – Barmar May 23 '13 at 15:57

1 Answers1

0

The referer is the page that referred the browser to the current URL, so getting the last URL is to be expected, and desired.

If you want the URL of the current page then look at $_SERVER['REQUEST_URI'] instead.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335