https://creatory.biz/hubfs/hub_generated/template_assets/1/5273292…/template_tracking-general.min.js
1window.dataLayer=window.dataLayer||[];const ComponentType=["sidebar","top-banner","bottom-sticky","hero-image","survey","top-nav","pop-up","above-footer","middle","footer","tooltip","exit-pop-up","before-footer","lightbox-edm-pop-up","vertical-tiles","body","faq"],EventType=["navigate","subscribeClick"],ActionType=["view","click","expand","collapse"],VerticalType={CC:"CreditCard",PL:"PersonalLoan",TI:"TravelInsurance",CI:"CarInsurance",BA:"BankAccount",SA:"SecurityAccount",HI:"HomeInsurance",HL:"HomeLoan",IP:"InvestmentPlan"},CountryMarket={SG:"singsaver",HK:"moneyhero",TW:"money101",MY:"comparehero",PH:"moneymax"},track=(event,action,component,trackingData)=>ComponentType.includes(component)?EventType.includes(event)?ActionType.includes(action)?void dataLayer.push({componentType:component,event:event,action:action,...trackingData}):(console.log("Invalid action type. Please check back with analytics team that the proposed values are approved internally for use across the markets - "+action),!1):(console.log("Invalid event type. Please check back with analytics team that the proposed values are approved internally for use across the markets - "+event),!1):(console.log("Invalid component type. Please check back with analytics team that the proposed values are approved internally for use across the markets - "+component),!1),trackAny=trackData=>{location.hostname.match("hubspot")&&console.log(trackData),dataLayer.push(trackData)};function getVerticalCodeFromProductUid(productUid){const verticalCodeArray=productUid.split(".").filter((segment=>2==segment.length));let foundVerticalCode=null;return verticalCodeArray.forEach((verticalCode=>{VerticalType[verticalCode]&&(foundVerticalCode=verticalCode)})),foundVerticalCode}function getMarketFromProductUid(productUid){const marketArray=productUid.split(".").filter((segment=>2==segment.length));let foundMarket=null;return marketArray.forEach((market=>{CountryMarket[market]&&(foundMarket=market)})),foundMarket}function generateDataTrackClickJson(trackingData,event,location,verticalCode,action,componentType,title){const dataTrackClickJson={event:event,location:location,verticalCode:verticalCode,action:action,componentType:componentType,title:title,...trackingData};return JSON.stringify(dataTrackClickJson)}function updateEcommerceData(eCommerceData,pos,filterKeys,moveProductIntoClick,moveFilterIntoClick,substituteClickKey){if(pos&&(eCommerceData.ecommerce.products[0].position=pos),filterKeys&&(eCommerceData.ecommerce.filter=formatFilterKeysForTracking(filterKeys)),moveProductIntoClick){const productData=eCommerceData.ecommerce.products;eCommerceData.ecommerce.click.products=productData,delete eCommerceData.ecommerce.products}if(moveFilterIntoClick){const filterData=eCommerceData.ecommerce.filter;eCommerceData.ecommerce.click.filter=filterData,delete eCommerceData.ecommerce.filter}let clickKey="click";if(substituteClickKey){const clickData=eCommerceData.ecommerce.click;eCommerceData.ecommerce[substituteClickKey]=clickData,delete eCommerceData.ecommerce.click,clickKey=substituteClickKey}return eCommerceData}function generateEcommerceTrackingData(trackingBadgePromos,promoLabels,productTypename,productProviderName,productName,productTitle,currency){return"undefined"==typeof pageVerticalList&&console.error("Common Page Events and Settings not configured or not added into template"),{ecommerce:{currencyCode:currency??"",click:{actionField:{list:"undefined"!=typeof pageVerticalList?pageVerticalList:""}},products:[{category:productTypename,brand:productProviderName,name:productName,id:productTitle,dealStatus:!0,promoLabel:promoLabels?.join("|")??"",promotion:trackingBadgePromos?.join("|")??""}]}}}function getEcommerceDataFromNode(productCardNode,pos,filterKeys,moveProductIntoClick,moveFilterIntoClick,substituteClickKey,addSeeMoreText){let eCommerceData=null,comparableDetails=[];try{let strECommerceData=productCardNode.getAttribute("data-ecommerce");eCommerceData=JSON.parse(strECommerceData)}catch(e){console.log("productCard has no value for data-ecommerce or unable to parse as JSON")}if(eCommerceData){productCardNode.querySelectorAll(".product-card-comparable-items div[data-comparable-id]").forEach((comparableNode=>{comparableDetails.push(comparableNode?.innerText?.replaceAll("\n"," "))}));let price=productCardNode.querySelector('.product-card-comparable-items div[data-comparable-key="REPAYMENT"]')?.innerText;eCommerceData.ecommerce.products[0].productDetails=comparableDetails.join("|"),eCommerceData.ecommerce.products[0].price=price?parseFloat(price.replace(/\D/g,"")):0,eCommerceData=updateEcommerceData(eCommerceData)}return eCommerceData=updateEcommerceData(eCommerceData,pos,filterKeys,moveProductIntoCl
1ick,moveFilterIntoClick,substituteClickKey),addSeeMoreText&&(eCommerceData.ecommerce[substituteClickKey??clickKey].actionField.tabName=productCardNode.querySelector(".hyphen-accordian-toggle-area").hasAttribute("open")?"see less":"see more"),eCommerceData}document.addEventListener("DOMContentLoaded",(function(event){document.body.addEventListener("click",(event=>{const data=event.target.closest("[data-track-click]")?.getAttribute("data-track-click");data&&trackAny(JSON.parse(data))}),{passive:!0})}));const MARKET_CONFIG={money101:{currencyCode:"TWD",currencyPrefix:"NT$",locale:"zh-tw"},moneyhero:{currencyCode:"HKD",currencyPrefix:"HK$",locale:{en:"en-hk",zh:"zh-hk"}},moneyhero_en_hk:{currencyCode:"HKD",currencyPrefix:"HK$",locale:"en-hk"},moneyhero_zh_hk:{currencyCode:"HKD",currencyPrefix:"HK$",locale:"zh-hk"},moneyhero_zh_cn:{currencyCode:"CNY",currencyPrefix:"CN$",locale:"zh-cn"},singsaver:{currencyCode:"SGD",currencyPrefix:"S$",locale:"en-sg"},comparehero:{currencyCode:"MYR",currencyPrefix:"RM",locale:"en-my"},moneymax:{currencyCode:"PHP",currencyPrefix:"â±",locale:"en-ph"}};function getMarketFromHostname(hostname){for(let marketConfigKey in MARKET_CONFIG)if(hostname.indexOf(marketConfigKey)>0)return marketConfigKey;console.log("NOT FOUND TEST ENV");const headerLogo=document.querySelector(".header-logo");for(let marketConfigKey in MARKET_CONFIG){if(headerLogo?.getAttribute("href").indexOf(marketConfigKey)>0)return marketConfigKey;console.log("Page has no market logo")}return"singsaver"}function getLocaleFromUrl(){const market=getMarketFromHostname(window.location.hostname);if("moneyhero"!=market){return{singsaver:"",money101:"zh_tw",moneymax:"en_ph",comparehero:"en_my"}[market]}{const pathFragments=window.location.pathname.split("/");if(pathFragments.find((pathFragment=>"en"==pathFragment)))return"en_hk";if(pathFragments.find((pathFragment=>"zh"==pathFragment)))return"zh_hk"}return null}function getTrackingCurrencyCode(market){return MARKET_CONFIG[market]?.currencyCode}function getTrackingLocale(market){if("moneyhero"!==market)return MARKET_CONFIG[market]?.locale;window.location.pathname.split("/").forEach((segment=>{const locale=MARKET_CONFIG[market]?.locale[segment];if(locale)return locale}))}function formatFilterKeysForTracking(filterKeys){return{filterAmount:filterKeys.loanAmount,filterPeriod:filterKeys.tenureInMonth,filterRate:filterKeys.apr}}window.MARKET_CONFIG=MARKET_CONFIG; 2//# sourceURL=https://25174313.fs1.hubspotusercontent-eu1.net/hub/25174313/hub_generated/template_assets/52732923079/1728355291198/Website_2022/Js/tracking-general.js
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.