Created
September 25, 2017 13:19
-
-
Save seer-interactive/5e39530a500eb3731257c916afceb5eb to your computer and use it in GitHub Desktop.
User Scoring
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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