const AFPStats = { baseUrl: 'https://affiplatform.com', websiteId: '', afpfuid: '', init: function (baseUrl, afpfuid, websiteId) { this.baseUrl = baseUrl; this.afpfuid = afpfuid; this.websiteId = websiteId; }, collect : function (path, callback) { var url = new URL(this.baseUrl + '/afpstats/collect'); var afpbuid = this.getCookie("afpbuid"); var params = {afpbuid: afpbuid, afpfuid: this.afpfuid, websiteId: this.websiteId, path: path}; url.search = new URLSearchParams(params).toString(); fetch(url) .then((response) => response.json()) .then((data) => { callback(data); }); }, getCookie: function(name) { function escape(s) { return s.replace(/([.*+?\^$(){}|\[\]\/\\])/g, '\\$1'); } var match = document.cookie.match(RegExp('(?:^|;\\s*)' + escape(name) + '=([^;]*)')); return match ? match[1] : null; }, setCookie: function(name, value, days) { var d = new Date; d.setTime(d.getTime() + 24*60*60*1000*days); document.cookie = name + "=" + value + ";path=/;expires=" + d.toGMTString(); }, uuidv4: function () { return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8); return v.toString(16); }); } } var baseUrl = 'https://affiplatform.com'; var afpfuid = '76f8a0d5-b21a-436c-8dd8-4e7e31acfeda'; var websiteId = '45'; var path = window.location.pathname + window.location.search; AFPStats.init(baseUrl, afpfuid, websiteId); AFPStats.collect(path, function (data){ if (typeof gtag !== "undefined") { gtag('event', 'page_view', { 'event_callback': function () { window.location.href = 'https://tp.media/r?marker=173543&trs=16608&p=4115&u=https%3A%2F%2Fhotellook.com&campaign_id=101'; } }); } else { window.location.href = 'https://tp.media/r?marker=173543&trs=16608&p=4115&u=https%3A%2F%2Fhotellook.com&campaign_id=101'; } });