(function() { var a = 'saot-st'; var d = 'https://api.apparell.com/api/tracking/' + a + '/collect' var getCookie = function() { const name = '_apparell' + '='; const cDecoded = decodeURIComponent(document.cookie); const cArr = cDecoded.split('; '); let res; cArr.forEach(val => { if (val.indexOf(name) === 0) res = val.substring(name.length); }) return res }; var cookie = getCookie() || '107f17d8-2fd5-46e9-bc5d-21a00fd39703'; var expires = 'expires=' + new Date(Date.now() + 31536000000); document.cookie = '_apparell' + '=' + cookie + '; ' + expires + '; path=/'; var getDefaultParams = function() { var x = 'connection=' + encodeURI(navigator.userAgent); x = x + '&lang=' + encodeURI(navigator.language); x = x + '&referer=' + encodeURI(document.referrer); x = x + '&url=' + encodeURI(window.location.href); x = x + '&cookie=' + cookie; return x }; var sendData = function(data) { var r = new window.XMLHttpRequest; r.open('POST', d, true); r.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); r.send(getDefaultParams() + data); }; var initListeners = function() { sendData('&live=1'); document.onvisibilitychange = function() { if (document.visibilityState === 'hidden') { sendData('&live=0'); } else { sendData('&live=1'); } }; }; sendData('&live=1'); }).call(this);