Forum Moderators: phranque

Message Too Old, No Replies

Passing parameter from URL to URL through a link

         

juicyjuice

7:42 pm on Dec 29, 2004 (gmt 0)

10+ Year Member



Im stuck on this problem, so im hoping someone can help me out.

I need to take a parameter from the url, example: www.xyz.com/?src=google, and make all links on the page go to pages determined by the source. so when a person clicks on a link, it will take them to page1 for src=google, page2 for src=overture, etc.

The reason I need to do this is becuase traffic comes in from different source, but as they navigate the site and then click links to go to different merchants, I lose track of where they came from.

I hope I was able to explain what im trying to do.
:)

Thanks

richant

8:18 pm on Dec 29, 2004 (gmt 0)

10+ Year Member



could u give a clearer example fit for a dummy 2 understand.

juicyjuice

8:32 pm on Dec 29, 2004 (gmt 0)

10+ Year Member



Sure i can clarify....

on my site I have a link. I want this link to change based on the source the visitor comes from. So when a person comes from google, they land on the page www.xyx.com/?=google , so i want to take the query string "google" and append it to my url in the link on my page. so they will be sent to www.xyz.com/google.

Now on this SAME page, if the person came from overture, they land at www.xyz.com/?=overture and i want them to go to www.xyz.com/overture when they click the SAME link as the person that came from google...

I want the query string to be passed along with the peron as they navigate my site until they find something they want to purchase, and are taken from my site to one of my merchants sites. when this happens, id liek to know whether this customer came from google or overture....

Did this help at all or make it worse? :)

topr8

9:18 pm on Dec 29, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



you could also just set a cookie when they hit the site, with a value of google or overture or whatever and then when they checkout grab the cookie and you'll be able to see where they came from.

juicyjuice

9:23 pm on Dec 29, 2004 (gmt 0)

10+ Year Member



they dont checkout on my site... its an information site that sends them offsite to merchants. So unfortunately, the cookie woudlnt help me.

topr8

9:29 pm on Dec 29, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



in which case grab the parameter from the url, write it to a variable

then on the page dynamically append the variable to every link on the page, you will need to use server site scripts to do this, either asp or php or whatever, there may be a long winded way of doing this clientside with javascript but i'm not sure how

eg something like (for asp)

linkfrompage.asp

will become

linkfrompage.asp?ref=<%=myvariable>

topr8

9:32 pm on Dec 29, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



hold on maybe i misunderstood you,

but if

>>its an information site that sends them offsite to merchants

you still won't know what link they clicked (unless you use a clickcounter and if so why not use cookies anyway)

garann

12:04 am on Dec 30, 2004 (gmt 0)

10+ Year Member



there may be a long winded way of doing this clientside with javascript but i'm not sure how

If you don't have a server-side language available to you, Javascript is not too much worse for this. You would need to parse the URL to get the parameter passed in, which is sort of messy business, but otherwise it's just tedious. This example should be close:


<script type="text/javascript">
function setLinks() {
var param = location.href.split("?")[1].split("=")[1];
if (param=="google") {
document.getElementById("linkOne").href = "googlePage.html";
} else {
document.getElementById("linkOne").href = "notGooglePage.html";
}
}
</script>
<body onload="setLinks">
<a href="somePage.html" id="linkOne">Visit our sponsor</a>
...