Click to See Complete Forum and Search --> : javascript that stores Referring URL in cookie then prints Referring URL


nat
06-11-2003, 03:50 AM
I searched 1,000's of javascripts and google and these forums. All I need is a javascript that creates a cookie that shows the 'Referring URL' (and only that 1 page even if the user browses to another page on my site that has the same javascript code on it) and a 'Personal Text Tracking Code' that I set in the Javascript on that particular page.

Javascript 1 - Create Cookie:
1. User goes to https://www.mydomain.com/index.html
A. Referring URL (if there is one) gets stored in a cookie
B. Tracking Code set in the javascript on that index.html page also gets stored in the cookie

Javascript 2 - Get Info From Cookie:
2. If User goes to https://www.mydomain.com/order/orderform.cgi (an html page is shown with javascript 2 in it)
A. Referring URL gets Printed out in the html of that page
B. Tracking Code in cookie gets Printed out in the html of that page


I can then by myself pass the info along to my Existing form processing perl script using html: <input type="hidden" name="referrer" value="[ <SCRIPT>document.wri.....javascript 2 code here.......</SCRIPT> ]">

User clicks Submit. I get the info.

pyro
06-11-2003, 07:16 AM
javascript can't get the referrer reliably. You are going to be better off with a server side language, and, if this is for referral tracking, the best way would be to give the people referral numbers, and have them link to your site like this: http://www.yourdomain.com/index.php?refid=10322. You can then strip the query string, and get the referer.