Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
User Scoring
<script>
var yourDomain = "insertyourdomainnamehere.com";
//scoring
var curRes = {{residential value}} || 0;
var curCom = {{commercial value}} || 0;
//set cookie expiration
//set now to current date
var now = new Date();
//set time using today's date from var now, get the full year associated with it ie: 2017
var time = now.getFullYear();
//set expireTime equal to two years + time ie: 2019
var expireTime = time + 2;
//set now's year to expireTime ie: today + 2 years
now.setFullYear(expireTime);
//for a residential tag (for commercial tag change to curCom++
curRes= curRes + 1;
//math to figure out what profile they're in
//create the curProfile variable
var curProfile = "";
//if residential is bigger than commercial
if(curRes > curCom){
curProfile = "residential";
//if commmerical is bigger than residental
}else if(curRes < curCom){
curProfile = "commercial";
//if they're equal
}else{
curProfile = "balanced";
}
//reset all cookie values
document.cookie= "ltr=" + curRes + ";expires=" + now.toGMTString() + ";domain=" + yourDomain + ";path=/";
document.cookie= "ltc=" + curCom + ";expires=" + now.toGMTString() + ";domain=" + yourDomain + ";path=/";
document.cookie= "ltp=" + curProfile + ";expires=" + now.toGMTString() + ";domain=" + yourDomain + ";path=/";
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.