Record the a user's webmail service?

In emails that contain activation links to start an account, I’d like to track where the link was clicked, such as when it was clicked from an online email service, like gmail, yahoo, hotmail, etc. Is this possible by just getting the return of $_SERVER['HTTP_REFERRER'] when the user visits the activation page, or is there anything else involved? (I know the email is available from the email address of a user, which I also collect, but I’m looking for anomalies such as when the email address and the domain the user clicked the link from do not match.)

Yes, $_SERVER['HTTP_REFERER'] [1] would work, although it must be noted that if your website is not on HTTPS, but the site where the user if coming from is (and lots, if not all, email sites are), then $_SERVER['HTTP_REFERER'] is empty. If you want information from all sites, make sure to redirect to an HTTPS domain in your email.

[1] Although the correct word is referrer with 2 R, there is an error in the spec that stuck, and you get a HTTP_REFERER with just 1 R instead.

PS. When typing something like $_SERVER[‘HTTP_REFERER’], make sure to either put backslashes before the underscores ($\_SERVER[‘HTTP\_REFERER’]) or enclose it in backticks (`$_SERVER[‘HTTP_REFERER’]`), because _ is for italics on this forum, so it would turn out like this: $_SERVER[‘HTTP_REFERER’], which is clearly not what you want :wink:

1 Like

Thanks Scallio, very useful info, especially about referring to an https page. And I am still getting used to this forum. (The text input area is so small… and I have to drag every time to make it larger. Sort of a pain right now.)

I know about the “referer” naming, but thanks for pointing it out. I should have spelled it “correctly” but bad habits die hard. :slight_smile:

1 Like