Skip to content

Instantly share code, notes, and snippets.

@seedprod
Created January 19, 2021 18:02
Show Gist options
  • Save seedprod/cd50ae142b4bd992ba84528412d85843 to your computer and use it in GitHub Desktop.
Save seedprod/cd50ae142b4bd992ba84528412d85843 to your computer and use it in GitHub Desktop.
<script>
function set_fta(){
var t = Math.round((new Date()).getTime() / 1e3);
var p = '';
var b = document.body;
if (this.fta_h_c(b,'single-post')) {
p = 'b--'
}
var n = location.pathname;
var r = document.referrer;
var s = location.search;
var c = this.fta_g_c('_fta');
if (c === undefined) {
// set first touch
var c =[];
c[0] = t; // timestamp
c[1] = p + n; // path
c[2] = r; // referrer
c[3] = s; //query
this.fta_s_c('_fta', c.join('|'), 365);
}
}
function fta_h_c(e, c) {
return (' ' + e.className + ' ').indexOf(' ' + c+ ' ') > -1;
}
function fta_s_c(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=/";
}
function fta_g_c(cname) {
var name = cname + "=";
var decodedCookie = decodeURIComponent(document.cookie);
var ca = decodedCookie.split(';');
for(var i = 0; i <ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == ' ') {
c = c.substring(1);
}
if (c.indexOf(name) == 0) {
return c.substring(name.length, c.length);
}
}
return undefined;
}
set_fta();
  </script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment