Rotate Affiliate URL Script?

Status
Not open for further replies.

AdHustler

New member
Aug 24, 2007
4,377
44
0
anyone have a simple script to rotate multiple affiliate urls on an outgoing link and hide the referrer? Im looking for one that does this without iframes. Thanks in advance.
 


I didn't test this but I think this should work to choose a random URL. You could just use this to link to your own referral hiding script and redirect to the affiliate offer from there.

Code:
<script type="text/javascript">
var rnd_url = new Array(
'<a href="URL1">Link Text</a>',
'<a href="URL2">Link Text</a>',
'<a href="URL3">Link Text</a>',
'<a href="URL4">Link Text</a>',
'<a href="URL5">Link Text</a>'
);
var rand = Math.floor(Math.random()*rnd_url.length);
rnd_url = rnd_url[rand];
document.write(rnd_url);
</script>
 
use php to hide what you're doing from the Search Engines.

Code:
<?php
//array filled with links (text, URL)
//generated at www.seoname.net
$feature_stuff = array(
array('URL 1', 'http://'),
array('URL 2', 'http://'),
array('URL 3', 'http://'));
//echo random link
$rand = rand(0, count($feature_stuff)-1);
echo '<li><a href="' . $feature_stuff[$rand][1] . '">' . $feature_stuff[$rand][0] . '</a></li>';
?>
 
Last edited:
Or using this you can control how its formatted easier.

Code:
<?php
//array filled with links (text, URL)
//generated at [URL="http://www.seoname.net"]www.seoname.net[/URL]
function randlink($links)
{
 $r_index = rand(0, count($links) - 1); // Get random index within list range
 list($name,$url) = $links[ $r_index ]; // Grab name and URL of random array element
 
 return sprintf('<li><a href="%s">%s</a></li>', $url,$name); // Format a lnk string and return it
}
//array filled with links (text, URL)
$links = array(
 array('URL 1', 'http://'),
 array('URL 2', 'http://'),
 array('URL 3', 'http://')
);
//echo random link
echo randlink($links);
?>
 
Status
Not open for further replies.