{ let pvCount = parseInt(localStorage.getItem(“pvCounter”)) || 0; pvCount = pvCount + 1; window.adiData.pvCount = pvCount; localStorage.setItem(‘pvCounter’, window.adiData.pvCount); } // Get a localstorage value that has an expiry date, remove it if expired – first used for REVGEN-1096 – Brought over from Revgen for AB test const getLSwExpiryDate = (key) => { const lsValue = localStorage.getItem(key); if (!lsValue) { return null; } const LSitem = JSON.parse(lsValue); const now = new Date(); if (now.getTime() > LSitem.expires) { localStorage.removeItem(key); return null; } return LSitem.value; } const trackFlyby = () => { const pageViews = window.adiData.pvCount; let flybyValue = “true”; const flybyExists = getLSwExpiryDate(‘ls-alt-flyby’); if (pageViews >= 3 && flybyExists !== null) { flybyValue = “false”; window.adiData.rg_flyby = flybyValue; } else { window.adiData.rg_flyby = flybyValue; } } const highImpactTest = () => { if (typeof window !== ‘undefined’) { const pvCount = window.adiData.pvCount; if (pvCount <= 2 && !trackExp) { // randomly pick control or test group and set the rg_version to that value const testValues = ['t4_con', 't4_exp']; const random = Math.floor(Math.random() * testValues.length); window.adiData.rg_version = testValues[random]; trackExp = 'true'; // user is now in the AB test localStorage.setItem('inExp', 'true'); localStorage.setItem('inExpValue', window.adiData.rg_version); } else if (pvCount 2) { // those who reach pv3 graduate from the AB test and become frequent visitors window.adiData.rg_version = localStorage.getItem('inExpValue'); if (window.adiData.rg_version === 't4_con') { localStorage.setItem('inExpValue', 't4_con_grad'); window.adiData.rg_version = 't4_con_grad'; } else if (window.adiData.rg_version === 't4_exp') { localStorage.setItem('inExpValue', 't4_exp_grad'); window.adiData.rg_version = 't4_exp_grad'; } } } }; if (window.adiData.pageType === 'cal') { trackExp = localStorage.getItem('inExp'); if (!trackExp && localStorage.getItem("pvCounter") !== null && parseInt(localStorage.getItem("pvCounter")) > 2) { // these users are not being tracked in the AB test and already are on PV3 or more (they are not to be in the AB test) countPV(); trackFlyby(); localStorage.setItem(‘inExpValue’, ‘t0’); window.adiData.rg_version = ‘t0’; } else { countPV(); trackFlyby(); highImpactTest(); } } ]]>
