Random Link Wheel (Weighted)

Control the odds. This script selects a random destination, but allows you to bias the selection toward specific "high priority" URLs.

Odds: Prize (10%) vs Try Again (90%)

...

Copy the Script

<script>
function weightedLink() {
    var links = [];
    
    // Add "Common Page" 9 times (90%)
    for(var i=0; i<9; i++) links.push("common.html");
    
    // Add "Rare Page" 1 time (10%)
    links.push("rare.html");
    
    var r = Math.floor(Math.random() * links.length);
    window.location = links[r];
}
</script>

Frequently Asked Questions

We populate the array with duplicates. If 'Page A' is in the array 5 times and 'Page B' only once, 'Page A' has a 5x higher chance of being picked.

It is a very rudimentary form of A/B testing (Split Testing). For professional results, server-side tools or Google Optimize are recommended, but this works for simple experiments.

Yes. Before redirecting, you could fire an analytics event (like `ga('send', 'event', ...)`) to track which page was randomly selected.