<script>
$(function(){
var url = (window.location != window.parent.location) ? document.referrer: document.location;
var sourceParam = getUrlVars(url)["ref"];
$("#Avanade_Referral_URL").val(sourceParam);
})
function getUrlVars(url) {
var vars = [],
hash;
var hashes = url.slice(url.indexOf('?') + 1).split('&');
for (var i = 0; i < hashes.length; i++) {
hash = hashes[i].split('=');
vars.push(hash[0]);
vars[hash[0]] = hash[1];
}
return vars;
}
</script>
And here's our hidden form field values: