if (window.mics && window.mics._call) { const userEventTag = {"site_id":"2715","enable_experimental_features":false,"enable_local_segment_evaluation":false,"enable_installation_id_generation":false,"enable_tcf_v2_for_cookie_matching":true,"enable_goo_matching":true,"enable_apx_matching":true,"enable_id5_id":false,"enable_utiq_mtid":false,"custom_configuration":{}} ; const mumConf = {"channel_id":"2715","active":true,"mics_cookie_domain":null,"mics_cookie_domain_creation_ts":null,"mics_cookie_domain_last_modified_ts":null}; const cmp_ids = [352,308,5,449,247,379,440,10,385,384,340,404,185,417,436,25,14,125,421,46,416,448,316,443,321,376,348,84,353,397,280,61,221,396,411,428,312,292,6,380,439,302,260,28,392,297,424,407,429,21,165,92,229,361,435,329,224,317,388,141,420,403,9,225,77,212,129,371,134,105,2,311,343,237,412,425,430,264,279,444,423,291,59,413,259,27,445,335,236,181,350,382,54,406,113,419,76,7,318,434,303,387,323,213,198,330,345,367,399,306,299,3,438,431,167,35,426,162,374,112,123,355,63,282,414,327,409,441,31,72,386,446,231,450,363,218,104,304,258,351,390,401,171,418,58,433,383,287,235,246,300,447,432,410,168,405,183,422,273,242,294,341,79,437,415,332,427,47,200,68,442,369,90,227,354,309,222,364]; const enable_mum_id = JSON.parse(mumConf.active ?? userEventTag.enable_mum_id ?? true); const enable_id5 = JSON.parse(userEventTag.enable_id5_id ?? false); // Restrict from using forbidden registry mics._call("md_closer17", "addAllowedRegistry", ['0']); if (enable_id5) { mics._call("md_closer17", "addAllowedRegistry", ['4']); } const extra_allowed_registries = []; extra_allowed_registries.forEach(registry => mics._call("md_closer17", "addAllowedRegistry", [registry])); const fullLegacyConf = { ...(userEventTag.custom_configuration || {}), "cmp_ids": cmp_ids, "enable_local_segment_evaluation": JSON.parse(userEventTag.enable_local_segment_evaluation ?? 'false'), "segment_evaluator_uri": userEventTag.segment_evaluator_uri, "segment_definition_uri": userEventTag.segment_definition_uri, "enable_apx_matching": enable_mum_id && JSON.parse(userEventTag.enable_apx_matching ?? 'true'), "enable_goo_matching": enable_mum_id && JSON.parse(userEventTag.enable_goo_matching ?? 'true'), "enable_tcf_v2_for_cookie_matching": JSON.parse(userEventTag.enable_tcf_v2_for_cookie_matching ?? 'false'), "enable_mum_id": enable_mum_id, "enable_id5": enable_id5, "namespace": userEventTag.namespace, "site_token": userEventTag.site_token ?? (!userEventTag.dat_token ? "md_closer17" : undefined), "dat_token": userEventTag.dat_token ?? (!userEventTag.site_token ? "md_closer17" : undefined), "device_id_registry_token_to_id_map": userEventTag.device_id_registry_token_to_id_map ?? {}, "mics_cookie_domain": userEventTag.mics_cookie_domain, "mics_cookie_domain_creation_ts": userEventTag.mics_cookie_domain_creation_ts, "mics_cookie_domain_last_modified_ts": userEventTag.mics_cookie_domain_last_modified_ts, }; mics._call("md_closer17", 'setConfig', [fullLegacyConf]); const mumIdConf = {"channel_id":"2715","active":true,"mics_cookie_domain":null,"mics_cookie_domain_creation_ts":null,"mics_cookie_domain_last_modified_ts":null}; if (JSON.parse(mumIdConf.active ?? 'true')) { mics._call("md_closer17", "addAllowedRegistry", ["mum"]); } else { mics._call("md_closer17", "deleteAdvertisingCookie", ["vid"]); } const installationIdConfiguration = {"channel_id":"2715","device_id_registry_id":null,"device_id_registry_token":null,"active":false} ; if (installationIdConfiguration.device_id_registry_token) { if (JSON.parse(installationIdConfiguration.active ?? 'false')) { mics._call("md_closer17", "addAllowedRegistry", [installationIdConfiguration.device_id_registry_token]); mics._call( "md_closer17", 'upsertAdvertisingCookie', ["ins", installationIdConfiguration.device_id_registry_token, "aNmRlNDNhNzItOGNhZS00YzU3LWEzNGYtNjAyNDM1NzU0M2Jm"] ); } else { mics._call("md_closer17", "deleteAdvertisingCookie", [installationIdConfiguration.device_id_registry_token]); } } const firstIdConf = {"channel_id":"2715","active":false}; if (JSON.parse(firstIdConf.active ?? 'false')) { mics._call("md_closer17", "addAllowedRegistry", ['first-id']); function readCookie(name) { const cookies = window.document.cookie.split(';'); for (let i = 0; i < cookies.length; i++) { const cookie = cookies[i].replace(/ /g, '').split('='); if (cookie[0] === name) { return cookie[1]; } } return undefined; } let firstIdValue; if (window.FIRSTID !== undefined && window.FIRSTID.getId !== undefined) { window.mics._call("md_closer17", "lodDebug", ['FIRSTID present, use FIRSTID.getId()']); firstIdValue = window.FIRSTID.getId(); } else if (window.firstId !== undefined && window.firstId.cookieName !== undefined) { window.mics._call("md_closer17", "lodDebug", ['only firstId conf present, use firstId.cookieName']); firstIdValue = readCookie(window.firstId.cookieName); } else { window.mics._call("md_closer17", "lodDebug", ['Nothing found, read cookie firstid']); firstIdValue = readCookie("firstid"); } window.mics._call("md_closer17", "lodDebug", ['firstIdValue = ' + firstIdValue]); if (firstIdValue) { window.mics._call("md_closer17", "_addIdentifier", ['USER_AGENT', {"$user_agent_id": `net:first-id:${firstIdValue}`}]); } } let utiqMtidConf = {"channel_id":"2715","active":false,"compartment_id":"20","compartment_token":"utiq-martechpass"}; if (JSON.parse(utiqMtidConf.active ?? 'false')) { function parseUtiqPass() { let parsedData = {}; try { const utiqPass = window.localStorage.utiqPass ?? "{}"; parsedData = JSON.parse(utiqPass); } catch (error) { window.console.error("Error parsing localStorage.utiqPass", error); } return parsedData; } function getExpirationDate() { let expirationDate = undefined; try { const utiqPass = parseUtiqPass(); expirationDate = Date.parse(utiqPass?.ids?.source?.connectId?.ttl); if (isNaN(expirationDate)) { expirationDate = undefined; } } catch (error) { window.console.error("Error parsing utiqPass?.ids?.source?.connectId?.ttl ", error); expirationDate = undefined; } return expirationDate; } function getMtidCategory(mtid) { const utiqPass = parseUtiqPass(); const utiqIdGraph = utiqPass?.ids?.source?.connectId?.idGraph || []; const category = utiqIdGraph.find(entry => entry.mtid === mtid)?.category; return category; } function getIdGraphEntry(entryName) { const entryOrError = window.Utiq.API.getIdGraphEntry(entryName); if (entryOrError.indexOf(' ') >= 0) { throw new Error(entryOrError); } return entryOrError; } function addUtiqIdentifier(mtid) { const expirationDate = getExpirationDate(); const mtidCategory = getMtidCategory(mtid); let account = { "$user_account_id": mtid, "$compartment_token": utiqMtidConf.compartment_token }; if (expirationDate) { account.$expiration_ts = expirationDate; } if (mtidCategory === "mobile") { window.mics._call("md_closer17", "_addIdentifier", ['USER_ACCOUNT', account]); } else { window.console.warn(`Utiq mtid is not of mobile category (=${mtidCategory}), not adding to identifiers`); } } let utiqFetchingIntervalId; function checkForUtiq() { if (window.Utiq && window.Utiq.API && window.Utiq.API.getIdGraphEntry) { try { addUtiqIdentifier(getIdGraphEntry('mtid')); } catch (e) { window.console.error('Error while fetching mtid from Utiq', e); } finally { if (utiqFetchingIntervalId) { clearInterval(utiqFetchingIntervalId); } } } } if (window.setInterval && window.setTimeout) { utiqFetchingIntervalId = setInterval(checkForUtiq, 500); setTimeout(() => { clearInterval(utiqFetchingIntervalId); }, 30000); } else { checkForUtiq(); } }; mics._call("md_closer17", 'markConfigAsLoaded', []); }