Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This is a problem because when I do email campaign, There is a link on the email, that link to my company homepage, I would like to differentiate between the visitor come from another way (e.g. search on google) or the visitor come from the email I have sent.

Is it able to check such kind of information ? Thankyou

share|improve this question
crossposted at SO:… – gnat Mar 17 '12 at 13:41
up vote 3 down vote accepted

Use the Javascript `document.referrer.hostname'. Note that it will be null if the user navigated to your page via the address bar, and it doesn't work in IE, so enclose it in a trycatch block.

For different email campaigns, modify their links. So have one email campaign go to the other to

To implement all this, create a php/jsp/asp file, landing.php that can record the email campaign. Make a similar bare-bones page, record.php, that records the sitename and IP. On every page of your site, add the javascript code. If the result isn't your sitename, blank, or null, have the JS AJAX-request the page record.php?fromsite=sitename&ip=IPAddress. Or something like that.

share|improve this answer
Thank you, as it is a email rather than a website (no real url, perhaps? can i find out that kind of information? Also, can it differentiate between mailcampaign 1 and mailcampaign 2? – user782104 Mar 17 '12 at 6:04
@user782104 fixed. – Manishearth Mar 17 '12 at 6:22
Instead of creating own code , Using google analytics would implement this? Thank you – user782104 Mar 17 '12 at 8:37
@user782104 yes, but the email campaign thing would not work. – Manishearth Mar 17 '12 at 8:51

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.