Forum Moderators: open

Message Too Old, No Replies

Ad tracking for the little people

capturing a url query to a cookia and retrieving it upon form submission

         

badjo

10:12 pm on Jun 6, 2005 (gmt 0)

10+ Year Member



Okay I have had some great professional help from this crowd and I am hoping I can get a bit more. I will post the final version so 101'ers like myself can use this process to track their CPA sales.

Here is what I want to do:

1. partners send traffic to my site with an assigned ID. www.mysite.com?id=1234

this page is an html page with product selections.

I want to automatically set a cookie that will capture my partners id: "1234"

2. The subsequent pages will be a multipage cgi form where they will enter their product selection and shipping information, etc.

I want to pull the id "1234" from the cookie and add it to a hidden
field on this page called "id" so when I submit the form the ID is
captured with the sale.

3. Below is the original code I have been trying to work with,
"actually butchering". This is the bare bones original script taken from a tutorial page. It sets the cookie when a form is clicked. I want to do it on page load. I can not even get that correct.

4. If someone is the mood to offer some help I think the elements are contained below I just do not know how to edit and arrange them so they can perform the function I described.

setting the cookie:
<SCRIPT LANGUAGE="JavaScript">

cookie_name = "dataCookie";
var YouEntered;

function putCookie() {

if(document.cookie!= document.cookie)
{index = document.cookie.indexOf(cookie_name);}
else
{ index = -1;}

if (index == -1)
{
YouEntered=document.cf.cfd.value;
document.cookie=cookie_name+"="+YouEntered+"; expires=Monday, 04-Apr-2010 05:00:00 GMT";
}

}
</SCRIPT>

Retrieving the cookie:

<SCRIPT LANGUAGE="JavaScript">
cookie_name = "dataCookie";
var YouWrote;

function getName() {
if(document.cookie)
{
index = document.cookie.indexOf(cookie_name);
if (index!= -1)
{
namestart = (document.cookie.indexOf("=", index) + 1);
nameend = document.cookie.indexOf(";", index);
if (nameend == -1) {nameend = document.cookie.length;}
YouWrote = document.cookie.substring(namestart, nameend);
return YouWrote;
}
}
}

YouWrote=getName();
if (YouWrote == "dataCookie")
{YouWrote = "Nothing_Entered"}

</SCRIPT>

badjo

10:31 pm on Jun 6, 2005 (gmt 0)

10+ Year Member



I left out this write part.
This is the code I was using, it writes to html. I want it to enter the id into a hidden field called "id".

<SCRIPT LANGUAGE="javascript">
document.write("You Entered " +YouWrote+ ".");
</SCRIPT>

<SCRIPT LANGUAGE="javascript">
document.write("<FORM>")
document.write("You Entered:")
document.write("<INPUT TYPE=text SIZE=30 VALUE=" +YouWrote+ ">");
document.write("</FORM>")
</SCRIPT>