Forum Moderators: open
I'm no expert in JavaScript, but thought this would be an easy one. After several hours of searching, I've simply ended up totally confused!
My client wants to trace the original/first HTTP referer of every visitor to his site. He wants his home page to write a cookie to the user's computer recording the referer domain. The php-driven inquiry form will then access the cookie and include the refer information in the notification to the client.
I'm not worried about the php side - but am having great trouble finding a reliable source for the JavaScript code to write the initial cookie. I thought this would be literally just a couple of lines of code, but studying the web it seems a lot more complex. Any help would be appreciated.
Thanks - but I can't have explained properly.
I can't use php because this is not all happening in the same session - and, even if it is, the reader will likely have started at the home page and read various other pages of the site, so the original referer will be long gone unless we trap it at the next page.
I am assuming that the user might not complete the inquiry form on their first visit to the site. They may well look at competitor services, consider things and then come back a few weeks later. So, the only way to store the 'orginal' referer is through a cookie. Yes, could use PHP to write the cookie as soon as they entered the site, but the regular pages aren't php-driven and so JavaScript seems the obvious way.