var TP_COOKIES = ['TP_UTM', 'TP_TRK', 'TP_REFERRER', 'TP_UTM_SOURCE','TP_UTM_MEDIUM', 'TP_UTM_CAMPAIGN', 'TP_UTM_CONTENT']; var TP_start = new Date(); var TP_TOPIC ="analytics-topic"; var TP_BUCKET="tp-web-analytics"; const TP_trackingScript_URL = "https://hello-ixm6jhfnca-uw.a.run.app/analytics/"; let TP_trackingScript=""; var TP_UUID = TP_getCookie("TP_UUID") || TP_generateUUID(); var TP_dt = new Date(); var TP_PV = TP_getCookie("TP_PV") || 0; TP_PV = parseInt(TP_PV) + 1; if (TP_PV == 1) { TP_setCookie('TP_FIRST_PAGE', window.location.href); } let TP_UTM = TP_getParameterByName("utm") || TP_getCookie("TP_UTM") || ""; let TP_TRK = TP_getParameterByName("trk") || TP_getCookie("TP_TRK") || ""; let TP_REFERRER = document.referrer || TP_getCookie("TP_REFERRER") || ""; let TP_UTM_SOURCE = TP_getParameterByName("utm_source") || TP_getCookie("TP_UTM_SOURCE") || ""; let TP_UTM_CAMPAIGN = TP_getParameterByName("utm_campaign") || TP_getCookie("TP_UTM_CAMPAIGN") || ""; let TP_UTM_MEDIUM = TP_getParameterByName("utm_medium") || TP_getCookie("TP_UTM_MEDIUM") || ""; let TP_UTM_CONTENT = TP_getParameterByName("utm_content") || TP_getCookie("TP_UTM_CONTENT") || ""; let TP_UTM_TERM = TP_getParameterByName("utm_term") || TP_getCookie("TP_UTM_TERM") || ""; let TP_FIRST_PAGE = TP_getCookie("TP_FIRST_PAGE") || document.URL; var TP_PAGE_LOAD_TIME="NULL"; try { TP_PAGE_LOAD_TIME = window.performance.timing.domContentLoadedEventEnd- window.performance.timing.navigationStart; } catch(e) { } TP_setCookie("TP_UUID", TP_UUID); TP_setCookie("TP_PV", TP_PV); TP_setCookie("TP_UTM", TP_UTM); TP_setCookie("TP_TRK", TP_TRK); TP_setCookie("TP_REFERRER", TP_REFERRER); TP_setCookie("TP_UTM_SOURCE", TP_UTM_SOURCE); TP_setCookie("TP_UTM_MEDIUM", TP_UTM_MEDIUM); TP_setCookie("TP_UTM_CAMPAIGN", TP_UTM_CAMPAIGN); TP_setCookie("TP_UTM_TERM", TP_UTM_TERM); TP_setCookie("TP_UTM_CONTENT", TP_UTM_CONTENT); TP_setCookie("TP_FIRST_PAGE", TP_FIRST_PAGE); let TP_PAYLOAD = {"DOMAIN": window.location.hostname, "TP_PAGE_LOAD_TIME": TP_PAGE_LOAD_TIME, "TP_UUID": TP_UUID, "TP_PV": TP_PV, "TP_TRK": TP_TRK, "TP_UTM": TP_UTM,"TP_REFERRER": TP_REFERRER, "TP_UTM_SOURCE": TP_UTM_SOURCE, "TP_UTM_MEDIUM": TP_UTM_MEDIUM, "TP_UTM_CAMPAIGN": TP_UTM_CAMPAIGN, "TP_UTM_TERM": TP_UTM_TERM, "TP_UTM_CONTENT": TP_UTM_CONTENT, "TP_FIRST_PAGE": TP_FIRST_PAGE, "FULL_URL": document.URL, "TP_BUCKET": TP_BUCKET, "TP_TOPIC": TP_TOPIC}; function TP_getParameterByName(name, 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]); } function TP_makeid(length) { var result = ''; var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; var charactersLength = characters.length; for ( var i = 0; i < length; i++ ) { result += characters.charAt(Math.floor(Math.random() * charactersLength)); } return result; } function TP_generateUUID() { // Public Domain/MIT var d = new Date().getTime();//Timestamp var d2 = ((typeof performance !== 'undefined') && performance.now && (performance.now()*1000)) || 0;//Time in microseconds since page-load or 0 if unsupported return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { var r = Math.random() * 16;//random number between 0 and 16 if(d > 0){//Use timestamp until depleted r = (d + r)%16 | 0; d = Math.floor(d/16); } else {//Use microseconds since page-load if supported r = (d2 + r)%16 | 0; d2 = Math.floor(d2/16); } return (c === 'x' ? r : (r & 0x3 | 0x8)).toString(16); }); } function TP_tracking_event(eventType, eventDetails){ var TP_end = new Date(); let TP_PAYLOAD_NEW = JSON.parse(JSON.stringify(TP_PAYLOAD)); let eventURL = ""; if (!eventType || eventType=="" || eventType=="page_view") { eventType='page_view'; eventURL = ""; } else { eventURL = "event"; } if (!eventDetails) { eventDetails='{}'; } TP_trackingScript=TP_trackingScript_URL+eventURL; function reqListener () { } TP_PAYLOAD_NEW.EVENT_TYPE = eventType; TP_PAYLOAD_NEW.EVENT_DETAILS = eventDetails; TP_PAYLOAD_NEW.TIME_SPENT = (TP_end - TP_start); const oReq = new XMLHttpRequest(); oReq.addEventListener("load", reqListener); oReq.open("POST", TP_trackingScript); oReq.send(JSON.stringify(TP_PAYLOAD_NEW)); return true; } function TP_setCookie(cname, cvalue) { const d = new Date(); d.setTime(d.getTime() + (365 * 24 * 60 * 60 * 1000)); let expires = "expires="+d.toUTCString(); document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/"; } function TP_getCookie(name) { let value = document.cookie; let parts = value.split(name+'='); if (parts.length === 2) return parts.pop().split(';').shift(); } // Automatically fire the page_view event here TP_tracking_event("page_view"); // backward compatability functions for mixpanel let mixpanel = {}; mixpanel.track = function(event_type, payload) { TP_tracking_event(event_type,payload); return true; } mixpanel.identify = function(MX_ID){ TP_tracking_event('MX_ID',MX_ID); return true; }; mixpanel.people = {}; mixpanel.people.set = function(MX_PEOPLE) { TP_tracking_event('MX_PEOPLE',MX_PEOPLE); return true; } mixpanel.people.alias = function(MX_ALIAS) { TP_tracking_event('MX_PEOPLE_ALIAS',MX_ALIAS); return true; } mixpanel.alias = function(MX_ALIAS) { TP_tracking_event('MX_ALIAS',MX_ALIAS); return true; } function gtag(event_type, action, payload) { // backward compatablity for GA events // // gtag('event', , { // 'event_category': , // 'event_label':