(function () { function generateUUID() { var d = new Date().getTime(); if (typeof performance !== 'undefined' && typeof performance.now === 'function') { d += performance.now(); //use high-precision timer if available } return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) { var r = (d + Math.random() * 16) % 16 | 0; d = Math.floor(d / 16); return (c === 'x' ? r : (r & 0x3 | 0x8)).toString(16); }); } function createCookie(name, value, days) { var expires; if (days) { var date = new Date(); date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); expires = "; expires=" + date.toGMTString(); } else { expires = ""; } document.cookie = name + "=" + value + expires + "; path=/;domain=animaapp.io"; document.cookie = name + "=" + value + expires + "; path=/;domain=animaapp.com"; } // Read cookie function readCookie(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for (var i = 0; i < ca.length; i++) { var c = ca[i]; while (c.charAt(0) === ' ') { c = c.substring(1, c.length); } if (c.indexOf(nameEQ) === 0) { return c.substring(nameEQ.length, c.length); } } return null; } function param(object) { var encodedString = ''; for (var prop in object) { if (object.hasOwnProperty(prop)) { if (encodedString.length > 0) { encodedString += '&'; } encodedString += encodeURI(prop + '=' + object[prop]); } } return encodedString; } function getVisitorId() { var visitorId = readCookie('ana_visitorId'); if (!visitorId) { visitorId = generateUUID(); createCookie('ana_visitorId', visitorId); } return visitorId; } function getParameterByName(name, url) { if (!url) url = window.location.href; name = name.replace(/[\[\]]/g, "\\$&"); var regex = new RegExp("[?&]" + name + "(=([^]*)|&|#|$)"), results = regex.exec(url); if (!results) return null; if (!results[2]) return ''; return decodeURIComponent(results[2].replace(/\+/g, " ")); } window.trackEvent = function (eventAction, params) { var visitorId = getVisitorId(); var page = ''; if (document.getElementById('anPageName')) { page = document.getElementById('anPageName').value; } var args = { 'eventCategory': 'General', 'eventAction': eventAction, 'url': encodeURIComponent(window.location.href), 'host': window.location.hostname, 'path': window.location.pathname, 'page': page, 'referrer': document.referrer, 'uid': visitorId }; if (params) { args['params'] = JSON.stringify(params); } var data = param(args); var http = new XMLHttpRequest(); http.withCredentials = true; var url = "//logs.animaapp.com/analytics/collect"; http.open("POST", url, true); http.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); http.send(data); }; window.submitted = function (event) { window.trackEvent('conversion'); } var utmMedium = getParameterByName('utm_medium'); var utmSource = getParameterByName('utm_source'); var utmCampaign = getParameterByName('utm_campaign'); var utmContent = getParameterByName('utm_content'); var args = {}; if (utmMedium) { args['utm_medium'] = utmMedium; createCookie('utm_medium', utmMedium); } if (utmSource) { args['utm_source'] = utmSource; createCookie('utm_source', utmSource); } if (utmCampaign) { args['utm_campaign'] = utmCampaign; createCookie('utm_campaign', utmCampaign); } if (utmContent) { args['utm_content'] = utmContent; createCookie('utm_content', utmContent); } window.trackEvent('pageview', args); window.Intercom('update', {user_id: getVisitorId()}); })();