Forum Moderators: phranque
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
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? :)
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>
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>
...