Forum Moderators: open
If someone clicks through to a site from Google Adwords, an external link in the code might be xyz.com?123
But if they come from Yahoo Search Marketing, the link would change to xyz.com?ABC
For example.
Thanks!
var appendQS;
if ( document.referrer.indexOf('www.example.com')> 0 ) {
appendQS = '?from=example.com'
} else {
appendQS = '?from=somewhereelse'
}
$("a").each(function(i){
var newRef;
newRef = $(this).attr('href')
newRef = newRef + appendQS
$(this).attr('href', newRef)
});
Keep in mind, this is a simplified example. Without some proper checking you could break some links (like email links, or links that already have a query string).