Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
865 B
10
Indexable
Never
<script>
// pegar os parametros da URL
function getUrlParam(name) {
    var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(window.location.href);
    return results ? decodeURIComponent(results[1]) || 0 : false;
}
 
// criar um cookie
function setCookie(cname, cvalue, exdays) {
    var d = new Date();
    d.setTime(d.getTime() + (exdays*24*60*60*1000));
    var expires = "expires="+d.toUTCString();
    document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
}
 
// checar se o parametro utm_sorce contem "fb"
var utm_source2 = getUrlParam('utm_source');
 
if (typeof utm_source2 === 'string' && utm_source2.includes("fb")) {
    setCookie("coming_from", "fb", 7); // cookie expira em 7 dias
}
if (typeof utm_source2 === 'string' && utm_source2.includes("gg")) {
    setCookie("coming_from", "gg", 7); // cookie expira em 7 dias
}
</script>
Leave a Comment