script type="text/javascript">
function setCookie(cname, cvalue){
var d = new Date();
var minutes = 480;
d.setTime(d.getTime() + (minutes * 60 * 1000));
var expires = "expires="+ d.toUTCString();
document.cookie = cname + "=" + cvalue + ";"+ expires +";path=/";
}
var vars = [], hash, gclid;
var hashes = window.location.href;
var decodedurl = decodeURIComponent(hashes);
var newurl = decodedurl.slice(window.location.href.indexOf('?') + 1).split('&');
for(var i = 0; i < newurl.length; i++)
{
hash = newurl[i].split('=');
vars.push(hash[0]);
vars[hash[0]] = hash[1];
}
if(vars['gclid']){ //checking if gclid parameter exists in URL
gclid = vars['gclid']; //storing GCLID value into a variable
setCookie("gclid",gclid); //setting cookie using the GCLID value
}