Professional Documents
Culture Documents
(function (w, d, p, u, a, t) {
"use strict";
function getTaggerId() {
try {
const item = localStorage.getItem('au/tid');
if (item !== null) {
const taggerId = JSON.parse(item);
return taggerId['v'];
}
return null;
}
catch (err) {
return null;
}
}
function getAudigentId() {
const fkey = '_au_1d=';
const decodedCookie = decodeURIComponent(document.cookie);
const ca = decodedCookie.split(';');
for (let i = 0; i < ca.length; ++i) {
let c = ca[i];
while (c.charAt(0) == ' ') {
c = c.substring(1);
}
if (c.indexOf(fkey) == 0) {
return c.substring(fkey.length, c.length);
}
}
return null;
}
function getCache() {
if (typeof (Storage) !== 'undefined') {
const ttl = parseInt(w.localStorage.getItem(K_TTL) || '0');
if (ttl > T0) {
return JSON.parse(w.localStorage.getItem(K_DATA));
}
}
return null;
}
function setCache(response) {
if (typeof (Storage) !== 'undefined' && response.segments.length > 0) {
const t1 = T0 + (5 * 60 * 1000);
w.localStorage.setItem(K_TTL, t1);
w.localStorage.setItem(K_DATA, JSON.stringify(response));
}
}
// trigger custom event to notify other libraries that the data is ready
d.dispatchEvent(new CustomEvent('auSegReady', { 'detail': response }));
if (withCache) {
setCache(response);
}
}
responseHandler(AU_SEG, false);
u = 'https://' + u + '/api/v1/segments?url=' +
encodeURIComponent(d.location.href) + '&partner_id=' + p;
a = getAudigentId();
if (typeof a === 'string') {
u = u + '&au_id=' + a;
}
t = getTaggerId();
if (typeof t === 'string') {
u = u + '&tagger_id=' + t;
}
responseHandler(cres, true);
}
})(window, document, '158', 'seg.ad.gt');