1class BloomreachEvents{static DEBUG=(()=>{const KEY='bloomreachDebug';try{const fromQuery=new URLSearchParams(window.location.search).get('debug')==='1';const fromHash=/(^|[#&])debug=1(?:&|$)/.test(window.location.hash);if(fromQuery||fromHash){window.localStorage.setItem(KEY,'1');return!0} 2return window.localStorage.getItem(KEY)==='1'}catch(err){return!1}})();static GA4_TO_BR={login:'login',sign_up:'registration',share_offer:'share_offer',submit_review_success:'submit_review_success',share:'share',comparison_drawer_opened:'operator_compare',sign_up_displayed:'sign_up_displayed',sign_up_start:'sign_up_start',login_displayed:'login_displayed',login_start:'login_start',};static NAV_CRITICAL={select_item:!0,exit_click_bonus_code:!0,};static _staticProps=null;constructor(){this.identified=!1;this.identifyFromDataLayer();this.bindDataLayerInterceptor();this.bindPageLoadEvents();this.bindConsentListener();BloomreachEvents.log('BloomreachEvents initialised')} 3static log(...args){if(BloomreachEvents.DEBUG){console.log('%c[Bloomreach]','color:#ff5722;font-weight:bold;',...args)}} 4static getCookie(name){const match=document.cookie.match(new RegExp('(^|;\\s*)'+name+'=([^;]*)'));return match?decodeURIComponent(match[2]):''} 5static readGeoFromHtml(){const root=document.documentElement;if(!root||!root.dataset){return''} 6const country=(root.dataset.country||'').trim();return country?country.toUpperCase():''} 7static readStateFromHtml(){const root=document.documentElement;if(!root||!root.dataset){return''} 8const state=(root.dataset.state||'').trim();return state?state.toUpperCase():''} 9static deriveGeo(){const locale=(typeof window.localeCode==='string')?window.localeCode:'';const parts=locale.split('_');return parts.length===2?parts[1].toUpperCase():''} 10static buildGlobalProps(){if(!BloomreachEvents._staticProps){const stateFromHtml=BloomreachEvents.readStateFromHtml();const stateFromGlobal=(typeof window.userState==='string'&&window.userState)?window.userState:'';BloomreachEvents._staticProps={geo:BloomreachEvents.readGeoFromHtml()||BloomreachEvents.getCookie('geo_location')||BloomreachEvents.deriveGeo(),state:stateFromHtml||stateFromGlobal||BloomreachEvents.getCookie('user_state'),market:BloomreachEvents.getCookie('market_segment'),}} 11return Object.assign({},BloomreachEvents._staticProps,{timestamp:new Date().toISOString(),})} 12static deferNonCritical(fn){if(typeof window!=='undefined'&&typeof window.requestIdleCallback==='function'){window.requestIdleCallback(fn,{timeout:500})}else{setTimeout(fn,0)}} 13static track(eventName,properties){if(!eventName){return} 14const payload=Object.assign({event:eventName},BloomreachEvents.buildGlobalProps(),properties||{});payload.event=eventName;try{if(window.exponea&&typeof window.exponea.track==='function'){window.exponea.track(eventName,payload);BloomreachEvents.log('track â',eventName,payload)}else{BloomreachEvents.log('SDK missing, dropped â',eventName,payload)}}catch(err){BloomreachEvents.log('track error',err)}} 15identifyFromDataLayer(){const dl=window.dataLayer||[];for(let i=dl.length-1;i>=0;i--){const entry=dl[i];if(entry&&typeof entry==='object'&&entry.user_id){this.identify(entry.user_id);break}}} 16identify(userId){if(!userId||this.identified===userId){return} 17this.identified=userId;try{if(window.exponea&&typeof window.exponea.identify==='function'){window.exponea.identify({registered:userId});
17BloomreachEvents.log('identify â',userId)}}catch(err){BloomreachEvents.log('identify error',err)}} 18bindDataLayerInterceptor(){window.dataLayer=window.dataLayer||[];const dl=window.dataLayer;for(let i=0;i<dl.length;i++){this.handleDataLayerEntry(dl[i])} 19const originalPush=dl.push.bind(dl);dl.push=(...args)=>{const result=originalPush(...args);args.forEach((entry)=>this.routeDataLayerEntry(entry));return result}} 20routeDataLayerEntry(entry){if(entry&&typeof entry==='object'&&BloomreachEvents.NAV_CRITICAL[entry.event]){this.handleDataLayerEntry(entry);return} 21BloomreachEvents.deferNonCritical(()=>this.handleDataLayerEntry(entry))} 22handleDataLayerEntry(entry){if(!entry||typeof entry!=='object'){return} 23if(entry.user_id&&(entry.event==='login'||entry.event==='sign_up'||entry.is_logged_in==='logged_in')){this.identify(entry.user_id)} 24const eventName=entry.event;if(!eventName){return} 25if(eventName==='select_item'&&entry.ecommerce&&Array.isArray(entry.ecommerce.items)&&entry.ecommerce.items[0]){BloomreachEvents.track('visit_operator',BloomreachEvents.mapVisitOperator(entry.ecommerce.items[0]));return} 26if(eventName==='exit_click_bonus_code'){BloomreachEvents.track('visit_operator',{operator:entry.operator||'',operator_item_id:entry.oplist_item_id||'',cta_location:'bonus_code',list_type:entry.list_type||'',});return} 27if(eventName==='comparison_drawer_opened'){BloomreachEvents.track('operator_compare',{operators_compared:BloomreachEvents.coerceCount(entry)});return} 28if(eventName==='sign_up'){BloomreachEvents.track('registration',BloomreachEvents.mapAuth(entry));return} 29if(eventName==='login'){BloomreachEvents.track('login',BloomreachEvents.mapAuth(entry));return} 30if(eventName==='share_offer'){BloomreachEvents.track('share_offer',BloomreachEvents.mapShareOffer(entry));return} 31if(eventName==='submit_review_success'){BloomreachEvents.track('submit_review_success',BloomreachEvents.mapSubmitReview(entry));return} 32if(eventName==='share'){BloomreachEvents.track('share',BloomreachEvents.mapShare(entry));return} 33if(BloomreachEvents.GA4_TO_BR[eventName]&&eventName!=='login'&&eventName!=='sign_up'){BloomreachEvents.track(BloomreachEvents.GA4_TO_BR[eventName],BloomreachEvents.passthroughProps(entry))}} 34static mapVisitOperator(item){const out={operator:item.operator||'',operator_item_id:item.operator_item_id||'',};const optional={offer_id:item.offer_id,offer_name:item.offer,position:item.position,cta_id:item.cta_id,cta_location:item.ctalocation,list_id:item.item_list_id,list_type:item.item_list_name,brand_id:item.brand_id,site_offer_id:item.site_offer_id,item_category:item.item_category,item_category5:item.item_category5,item_brand:item.item_brand,item_variant:item.item_variant,listlocation:item.listlocation,listlength:item.listlength,location_id:item.location_id,product:item.product,item_id:item.item_id,quantity:item.quantity,};Object.keys(optional).forEach((key)=>{if(optional[key]!==undefined&&optional[key]!==null&&optional[key]!==''){out[key]=optional[key]}});return out} 35static mapAuth(entry){const out={};if(entry.method)out.method=entry.method;if(entry.user_id)out.user_id=entry.user_id;return out} 36static mapShareOffer(entry){const out={};const offerId=entry.offer_id||entry.exit_offer_id||entry.offer||'';if(offerId)out.offer_id=offerId;if(entry.method)out.method=entry.method;if(entry.exit_operator)out.operator=entry.exit_operator;if(entry.list_id)out.list_id=entry.list_id;if(entry.list_type)out.list_type=entry.list_type;if(entry.position)out.position=entry.position;return out} 37static mapSubmitReview(entry){const out={};const reviewId=entry.review_id||entry.offer||entry.object_of_review||'';if(reviewId)out.review_id=String(reviewId);if(entry.operator)out.operator=entry.operator;if(entry.length_of_review!==undefined)out.length_of_review=entry.length_of_review;if(entry.average_rating_at_time_of_review!==undefined)out.rating=entry.average_rating_at_time_of_review;return out} 38static mapShare(entry){return{content_type:entry.content_type||'',content_id:entry.content_id||'',method:entry.method||'',}} 39static coerceCount(entry){const candidates=[entry.operators_compared,entry.value,entry.label];for(let i=0;i<candidates.length;i++){const num=parseInt(candidates[i],10);if(!Number.isNaN(num)){return num}} 40return 0} 41static passthroughProps(entry){const out={};
41Object.keys(entry).forEach((key)=>{if(key!=='event'){out[key]=entry[key]}});return out} 42bindPageLoadEvents(){const path=window.location.pathname;const body=document.body;const verticalType=BloomreachEvents.detectVerticalType(path);if(verticalType&&body&&body.classList.contains('toplist-page')){BloomreachEvents.track('vertical_visit',{vertical_type:verticalType,genre:BloomreachEvents.cleanTitle(),})} 43const isReviewPath=/\/(?:online-casinos|review)\//.test(path);if(isReviewPath&&body&&body.classList.contains('single-casino')){BloomreachEvents.track('view_review',{review_id:BloomreachEvents.extractSlug(path),})} 44if(body&&body.classList.contains('single-news')&&path.indexOf('/news/')!==-1){const newsMatch=path.match(/\/news\/([^/?#]+)/);BloomreachEvents.track('article_selected',{article_name:BloomreachEvents.cleanTitle(),genre:newsMatch?newsMatch[1]:'',})}} 45static detectVerticalType(path){if(/\/casino-bonus(\/|$)/.test(path))return'casino';if(/\/online-casinos(\/|$)/.test(path))return'casino';if(/\/slots(\/|$)/.test(path))return'slots';return''} 46static cleanTitle(){return(document.title||'').replace(/\s+/g,' ').trim()} 47static extractSlug(path){const segments=path.split('/').filter(Boolean);return segments.length?segments[segments.length-1]:''} 48bindConsentListener(){document.addEventListener('change',(e)=>{const target=e.target;if(!target||target.tagName!=='INPUT'||target.type!=='checkbox'){return} 49if(target.name!=='marketing_consent2[]'){return} 50const form=target.closest('form#wppb-register-user-member-registration');if(!form||!target.checked){return} 51BloomreachEvents.track('consent',{consent_type:'newsletter'})})}} 52if(document.readyState==='loading'){document.addEventListener('DOMContentLoaded',()=>new BloomreachEvents())}else{new BloomreachEvents()}
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.