(function() { function bxBootstrap() { var re = /bot|crawl|slurp|spider|mediapartners|headlesschrome|snap-prefetch|remotasks|woorank|uptime\.com|facebookexternalhit|facebookcatalog/i; if (re.test(navigator.userAgent) || navigator.userAgent == '') { return; } if (!(window.bouncex&&bouncex.website)) { var pushedData = []; if(window.bouncex && bouncex.push && bouncex.length){ pushedData = bouncex; } window.bouncex = {}; bouncex.pushedData = pushedData; bouncex.website = {"id":5415,"name":"Sunglass Hut","cookie_name":"bounceClientVisit5415","domain":"sunglasshut.comus","ct":"fp_local_storage","ally":0,"ei":0,"tcjs":"","cjs":"window.top.bouncex.tealiumTracker = function(campaignName, parentName, eventType) {\n\tvar tealium_data2track = window.top.tealium_data2track || [];\n\tvar speakingString = 'X-X-X-BounceX-'+ eventType;\n\ttealium_data2track.push({\n\t\t'id': speakingString,\n\t\t'Content_TestCampaign': parentName,\n\t\t'Content_TestVariation': campaignName\n\t});\n};\n\n/* https://www.wrike.com/open.htm?id=439784749 */\nwindow.top.bouncex.tealiumTrackerV2 = function(ca_id, eventType) {\n var campaign = bouncex.campaigns[ca_id];\n\tvar campaignLabel = campaign.ga_i.label.toLowerCase();\n\tvar childString = '';\n\tvar parentString = '';\n\n\tif (campaignLabel.indexOf('email capture') > -1 || campaignLabel.indexOf('capture email') > -1) {\n\t parentString += 'emailCapture ';\n\t} else if (campaignLabel.indexOf('cart') > -1) {\n\t parentString += 'cartRecovery ';\n\t} else if (campaignLabel.indexOf('checkout') > -1) {\n\t parentString += 'checkoutShaping ';\n\t} else {\n\t parentString += 'Campaign ';\n\t}\n\n\tparentString += campaignLabel.indexOf('mobile') > -1 ? 'M ' : 'D ';\n\tparentString += '('+campaign.pid+')';\n\n\tchildString += campaign.ttype === 'variation' ? 'variation ' : 'control ';\n\tchildString += '('+ca_id+')';\n\t\n\tvar tealium_data2track = window.top.tealium_data2track || [];\n\tvar speakingString = 'Bounce-'+ eventType;\n\n\ttealium_data2track.push({\n\t\t'id': speakingString,\n\t\t'Tool_Name_Abbreviation': 'BO',\n\t\t'Content_TestCampaign': parentString,\n\t\t'Content_TestVariation': childString\n\t});\n};\n\nwindow.top.bouncex.md5 = function(inputString) {\n var hc=\"0123456789abcdef\";\n function rh(n) {var j,s=\"\";for(j=0;j<=3;j++) s+=hc.charAt((n>>(j*8+4))&0x0F)+hc.charAt((n>>(j*8))&0x0F);return s;}\n function ad(x,y) {var l=(x&0xFFFF)+(y&0xFFFF);var m=(x>>16)+(y>>16)+(l>>16);return (m<<16)|(l&0xFFFF);}\n function rl(n,c) {return (n<>>(32-c));}\n function cm(q,a,b,x,s,t) {return ad(rl(ad(ad(a,q),ad(x,t)),s),b);}\n function ff(a,b,c,d,x,s,t) {return cm((b&c)|((~b)&d),a,b,x,s,t);}\n function gg(a,b,c,d,x,s,t) {return cm((b&d)|(c&(~d)),a,b,x,s,t);}\n function hh(a,b,c,d,x,s,t) {return cm(b^c^d,a,b,x,s,t);}\n function ii(a,b,c,d,x,s,t) {return cm(c^(b|(~d)),a,b,x,s,t);}\n function sb(x) {\n var i;var nblk=((x.length+8)>>6)+1;var blks=new Array(nblk*16);for(i=0;i>2]|=x.charCodeAt(i)<<((i%4)*8);\n blks[i>>2]|=0x80<<((i%4)*8);blks[nblk*16-2]=x.length*8;return blks;\n }\n var i,x=sb(\"\"+inputString),a=1732584193,b=-271733879,c=-1732584194,d=271733878,olda,oldb,oldc,oldd;\n for(i=0;i -1) {\n return;\n }\n bouncex.push(['item', item]);\n\n groupID = validateGroupId(groupID);\n bouncex.push(['view item', {\n 'item:id': item.id ,\n 'item:itemgroupid': groupID\n }]);\n\n bouncex.push(['select_sku', {\n 'item:id': item.id ,\n 'item:itemgroupid': groupID,\n 'item:feedid': 'US-' + skuID\n }]);\n\n bouncex.et.on(bouncex.document, 'ajaxComplete.wknd', function(e, xhr, settings){\n trackAJAXCart(e, xhr, settings, item.id);\n });\n trackCustomizeAtcClicked(item.id);\n },\n 10\n );\n}\n\n/* ---------------------------- CATEGORY TRACKING --------------------------- */\n\nfunction getItemIdsCat() {\n var ids = [];\n\n jQuery('.sgh-tile').each(function (i, e) {\n var url = jQuery(e).find('a').first().attr('href'),\n id = getIdFromUrl(url);\n\n if (id && ids.indexOf(id) < 0) {\n ids.push(id);\n }\n });\n\n return ids.join(',');\n}\n\nfunction getCategoryObject() {\n return {\n 'page:url': CLEAN_URL,\n 'items:ids': getItemIdsCat()\n };\n}\n\nfunction initializeCategoryEvents() {\n var categoryObj;\n\n bouncex.et.onTrue(\n function () {\n categoryObj = getCategoryObject();\n return !!categoryObj['items:ids'].length &&\n !!categoryObj['page:url'];\n },\n function () {\n bouncex.push(['view category', categoryObj]);\n },\n 10\n );\n}\n\n/* ------------------------------- CART EVENTS ------------------------------ */\n\nfunction fireAddToCart(itemId, replenItem) {\n\n var atcItem = { 'item:id': itemId };\n\n if (replenItem) {\n atcItem['cart:item'] = bouncex.stringify(replenItem);\n }\n bouncex.push(['add to cart', atcItem]);\n\n if (bouncex.vars.cart) {\n return;\n }\n bouncex.setVar('cart', true);\n}\n\nfunction trackCustomizeAtcClicked(itemId) {\n bouncex.et.on(bouncex.document, 'click.bxatc', function () {\n bouncex.setVar('customize_atc_id', itemId);\n }, '.customize__btn');\n}\n\nfunction trackCustomizeAtc() {\n if(bouncex.vars.customize_atc_id) {\n fireAddToCart(bouncex.vars.customize_atc_id);\n bouncex.setVar('customize_atc_id', false);\n }\n}\n\nfunction trackAJAXCart(e, xhr, settings, id) {\n var replenItem;\n\n // track prescription item ATC\n if (\n settings.url.indexOf('/rx/cart') > -1\n && settings.type === 'POST'\n && !bouncex.utils.url.getParam('bx_cart')\n && xhr.status === 200\n ) {\n fireAddToCart(id);\n }\n\n // track standard PDP ATC\n if (\n settings.url.indexOf('/AjaxOrderChangeServiceItemAdd') > -1\n && settings.type === 'POST'\n && !bouncex.utils.url.getParam('bx_cart')\n && xhr.status === 200\n ) {\n var dataItem = bouncex.utils.url.queryStringToObject(settings.data);\n\n replenItem = {\n 'catalogId': dataItem.catalogId,\n 'storeId': dataItem.storeId,\n 'langId': dataItem.langId,\n 'catEntryId': dataItem.catEntryId,\n 'quantity': 1\n };\n\n if (!id || !replenItem.catalogId || !replenItem.catEntryId) {\n return;\n }\n\n fireAddToCart(id, replenItem);\n }\n}\n\nfunction emptyCart() {\n if (bouncex.vars.cart &&\n bouncex.vars.cart_qty === 0 &&\n bouncex.website.pts === 'cart'\n ) {\n bouncex.push(['empty_cart']);\n bouncex.setVar('cart', false);\n }\n}\n\nfunction initializeCartEvents() {\n bouncex.et.cart.init({\n replenishmentType: 'ajax',\n replenish: function (cart) {\n var deferreds = [];\n\n cart.items.forEach(function (item) {\n deferreds.push(makeAjaxATCFunc(item));\n });\n\n deferreds.reduce(\n function (promise, func) {\n return promise.then(function () {\n return func();\n });\n },\n jQuery.Deferred().resolve([])\n )\n .then(replenComplete);\n }\n });\n\n function makeAjaxATCFunc(replenItem) {\n var replenUrl = 'https://www.sunglasshut.com//webapp/wcs/stores/servlet/AjaxOrderChangeServiceItemAdd';\n\n return function () {\n return jQuery.ajax({\n type: 'POST',\n url: replenUrl,\n data: bouncex.utils.url.generateQuerystring(replenItem)\n });\n };\n }\n\n function replenComplete() {\n jQuery.ajax({\n type: 'GET',\n url: 'https://www.sunglasshut.com/wcs/resources/store/10152/minicart'\n })\n .then(function(resp){\n bouncex.push(['cart replenish', {\n 'cart:success': resp.numberOfItems > 0\n }]);\n window.location.href = CLEAN_URL + '?bx_replen=true';\n });\n }\n\n emptyCart();\n}\n\n/* ------------------------------ USER TRACKING ----------------------------- */\n\nfunction initializeUserTracking() {\n if (!bouncex.vars.logged_in || !!bouncex.vars.logged_in_identified) {\n return;\n }\n\n var userEmail;\n\n bouncex.et.onTrue(\n function () {\n userEmail = bouncex.utils.getNestedProp('wishlist.profileDetails.objectPerson.registeredEmail');\n return bouncex.utils.validate.email(userEmail);\n },\n function () {\n bouncex.push([\n 'user',\n {\n 'email': userEmail,\n 'source': 'LoggedIn'\n }\n ]);\n bouncex.setVar('logged_in_identified', true);\n },\n 5\n );\n}\n\n/* --------------------------- INITIALIZE TRACKING -------------------------- */\n\nfunction isValidDomain() {\n return CLEAN_URL.indexOf('www.sunglasshut.com') > -1;\n}\n\nfunction isEnUS() {\n return bouncex.html.attr('lang') === 'en' && (CLEAN_URL.indexOf('/us') > -1 || bouncex.website.pts === 'cart');\n}\n\nfunction isValidForTracking() {\n return isValidDomain() && isEnUS();\n}\n\nfunction init() {\n if (!isValidForTracking()) {\n return;\n }\n\n initializeUserTracking();\n initializeCartEvents();\n\n switch (bouncex.website.pts) {\n case 'category':\n case 'search':\n initializeCategoryEvents();\n break;\n case 'product':\n initializeItemEvents();\n break;\n case 'cart':\n trackCustomizeAtc();\n break;\n default:\n break;\n }\n bouncex.setVar('customize_atc_id', false);\n}\n\ninit();\n","dge":true,"bxidLoadFirst":false,"pie":true,"cme":true,"gbi_enabled":0,"bpush":false,"pt":{"cart":{"testmode":false,"val":[[{"activation":"current_page_url","prop":"contains","prop2":"","prop3":"","val":"AjaxOrderItemDisplayView"}]]},"category":{"testmode":false,"val":[[{"activation":"js","prop":"","prop2":"","prop3":"","val":"document.querySelectorAll('.bodyPlp').length > 0;"},{"activation":"js","prop":"","prop2":"","prop3":"","val":"document.querySelectorAll('.pageContentCodice').length > 0"}],[{"activation":"current_page_url","prop":"not_contains","prop2":"","prop3":"","val":"/au/"}]]},"checkout":{"testmode":false,"val":[[{"activation":"current_page_url","prop":"contains","prop2":"","prop3":"","val":"Checkout"}],[{"activation":"current_page_url","prop":"not_contains","prop2":"","prop3":"","val":"/CheckoutConfirmationView"}]]},"home":{"testmode":false,"val":[[{"activation":"js","prop":"","prop2":"","prop3":"","val":"bouncex.utils.getNestedProp('tealium_datacopy.Page_Section2', '') === 'Home';"}],[{"activation":"current_page_url","prop":"not_contains","prop2":"","prop3":"","val":"/au"}],[{"activation":"current_page_url","prop":"not_contains","prop2":"","prop3":"","val":"/ca-en"}],[{"activation":"current_page_url","prop":"not_contains","prop2":"","prop3":"","val":"/mx"}]]},"product":{"testmode":false,"val":[[{"activation":"js","prop":"","prop2":"","prop3":"","val":"document.querySelectorAll('#pdp').length > 0;"}],[{"activation":"current_page_url","prop":"not_contains","prop2":"","prop3":"","val":"/au/"}]]},"search":{"testmode":true,"val":[[{"activation":"current_page_url","prop":"contains","prop2":"","prop3":"","val":"SearchDisplay?"}]]}},"els":{"ALL_desktop_menu":".main-menu-right","blank_site_element":""},"vars":[{"name":"logged_in","polling":"all","persist":"visit","page_types":[],"testmode":false,"default":"false","code":"(function(){\n if (bouncex.website.pts === 'checkout') {\n return jQuery('#MCA_verifyLogonId').attr('value').length > 0;\n }\n if (window.location.href.indexOf('myaccount') > -1) {\n return jQuery('.info').text().indexOf('Hi') > -1;\n }\n if (jQuery('.main-menu-right .relative[href=\"/us/wishlist\"]').is(':visible')) {\n return jQuery('.info').text().indexOf('Hi,') > -1;\n }\n return null;\n})();","trigger":""},{"name":"ever_logged_in","polling":"all","persist":"permanent","page_types":[],"testmode":false,"default":"false","code":"bouncex.vars.logged_in || null;","trigger":""},{"name":"cart_qty","polling":"all","persist":"visit","page_types":[],"testmode":false,"default":"0","code":"bouncex.website.pts === 'checkout' ? null : Number(jQuery('.cart-counter').eq(0).text().replace(/[^0-9.]/g, ''));","trigger":""},{"name":"cart_value","polling":"all","persist":"visit","page_types":[],"testmode":false,"default":"0","code":"bouncex.website.pts === 'cart' ? Number(jQuery('#order_total .cost__info span, .cost__info').eq(0).text().replace(/[^0-9.]/g, '')) : null;","trigger":""},{"name":"prod_price","polling":"none","persist":"no","page_types":[],"testmode":true,"default":"false","code":"","trigger":""},{"name":"prod_name","polling":"none","persist":"no","page_types":[],"testmode":true,"default":"false","code":"","trigger":""},{"name":"in_stock","polling":"none","persist":"no","page_types":[],"testmode":true,"default":"false","code":"","trigger":""},{"name":"submitted_onsite","polling":"none","persist":"permanent","page_types":[],"testmode":false,"default":"false","code":"window.location.href.indexOf('thank-you-page') > -1 || null;","trigger":""},{"name":"page_url","polling":"none","persist":"no","page_types":["category","search"],"testmode":true,"default":"false","code":"","trigger":""},{"name":"cart_token","polling":"none","persist":"no","page_types":[],"testmode":true,"default":"false","code":"null;","trigger":"pageload"},{"name":"cart_items","polling":"none","persist":"no","page_types":[],"testmode":true,"default":"false","code":"null;","trigger":"pageload"},{"name":"cart","polling":"none","persist":"permanent","page_types":[],"testmode":false,"default":"false","code":"null;","trigger":"pageload"},{"name":"cookie_modal_present","polling":"all","persist":"no","page_types":[],"testmode":false,"default":"false","code":"jQuery('.privacy_prompt1').is(':visible');","trigger":"pageload"},{"name":"page_type","polling":"all","persist":"no","page_types":[],"testmode":false,"default":"false","code":"bouncex.website.pts;","trigger":"pageload"},{"name":"logged_in_identified","polling":"none","persist":"visit","page_types":[],"testmode":false,"default":"false","code":"null;","trigger":"pageload"},{"name":"customize_atc_id","polling":"none","persist":"visit","page_types":[],"testmode":false,"default":"false","code":"null;","trigger":"pageload"},{"name":"cookie_acceptance","polling":"all","persist":"no","page_types":[],"testmode":false,"default":"false","code":"(function() {\n var cookies = document.cookie.split(';');\n var consentValue = null;\n for (var i = 0; i < cookies.length; i++) {\n var cookie = cookies[i].trim();\n if (cookie.indexOf('CONSENTMGR=') === 0) {\n consentValue = decodeURIComponent(cookie.substring('CONSENTMGR='.length));\n break;\n }\n }\n\n if (consentValue) {\n var parts = consentValue.split('|');\n for (var j = 0; j < parts.length; j++) {\n if (parts[j].indexOf('consent:') === 0) {\n var consentPart = parts[j].split(':');\n return consentPart[1] === 'true';\n }\n }\n }\n return false;\n})();","trigger":"pageload"}],"dgu":"pixel.cdnwidget.com","dgp":false,"ba":{"enabled":0,"fbte":0},"biu":"assets.bounceexchange.com","bau":"api.bounceexchange.com","beu":"events.bouncex.net","ibx":{"tjs":"","cjs":"","miw":0,"mibcx":1,"te":1,"cart_rep":{"get":"","set":""},"ulpj":null,"cus":"","miw_exclude":"","enabled":1},"etjson":null,"osre":true,"osru":"osr.bounceexchange.com/v1/osr/items","checkDfp":false,"gamNetwork":"","spa":0,"spatm":1,"preinit_cjs":"","crs":{"integrations":null,"pageCount":null},"mat":0,"math":0,"cpnu":"coupons.bounceexchange.com","dfpcms":0,"sms":{"optm":"","eventSharing":false,"shqId":"","enabled":0},"pde":true,"fmc":["AW","AI","AG","AR","BS","BB","BZ","BM","BO","BQ","BR","CA","KY","CL","CO","CR","CU","CW","DM","DO","EC","SV","GF","GL","GD","GT","GP","HT","HN","JM","MQ","MX","MS","NI","PA","PY","PE","PR","PM","MF","BL","KN","LC","VC","SX","SR","TT","US","UM","UY","VE","VG","VI"],"fme":true,"fmx":"","sdk":{"android":{"enabled":false,"enabledVersions":[],"eventModifications":null},"ios":{"enabled":false,"enabledVersions":[],"eventModifications":null}},"onsite":{"enabled":1},"ads":{"enabled":0},"pubs":{"enabled":0},"websdk":{"enabled":0},"ga4_property_id":"","ga4_measurement_id":"","tag_state_domain":"api.bounceexchange.com"} ; bouncex.tag = 'tag3'; bouncex.$ = window.jQuery; bouncex.env = 'production'; bouncex.restrictedTlds = {"casl":{"ca":1},"gdpr":{"ad":1,"al":1,"at":1,"ax":1,"ba":1,"be":1,"bg":1,"by":1,"xn--90ais":1,"ch":1,"cy":1,"cz":1,"de":1,"dk":1,"ee":1,"es":1,"eu":1,"fi":1,"fo":1,"fr":1,"uk":1,"gb":1,"gg":1,"gi":1,"gr":1,"hr":1,"hu":1,"ie":1,"im":1,"is":1,"it":1,"je":1,"li":1,"lt":1,"lu":1,"lv":1,"mc":1,"md":1,"me":1,"mk":1,"xn--d1al":1,"mt":1,"nl":1,"no":1,"pl":1,"pt":1,"ro":1,"rs":1,"xn--90a3ac":1,"ru":1,"su":1,"xn--p1ai":1,"se":1,"si":1,"sj":1,"sk":1,"sm":1,"ua":1,"xn--j1amh":1,"va":1,"tr":1}}; bouncex.client = { supportsBrotli: 1 }; bouncex.assets = {"ads":"005ab6b05ecd8ae76686b26c919990d4","creativesBaseStyles":"a53944a2","gpsAuction":"bbb80866120d17013073bb6d284cbd6b","inbox":"75060a85c1a4aebcc6f779b9e84db722","onsite":"abbdf7a49be9b52b097917b7b527b262","sms":"e39203556bab2366e56296ce42e974a7","websdk":"f0bbbaf6e9a27b2ca6b092b02959e95c"}; bouncex.push = function(pushData) { bouncex.pushedData.push(pushData); } var runtime = document.createElement('script'); runtime.setAttribute('src', '//assets.bounceexchange.com/assets/smart-tag/versioned/runtime_c81e76ee00d795b1eebf8d27949f8dc5.br.js'); runtime.setAttribute('async', 'async'); runtime.setAttribute('onload', 'bouncex.initializeTag()'); bouncex.initializeTag = function() { var script = document.createElement('script'); script.setAttribute('src', '//assets.bounceexchange.com/assets/smart-tag/versioned/main-v2_3240ed460a2f2a68a459053b6f0f3c3e.br.js'); script.setAttribute('async', 'async'); document.body.appendChild(script); var deviceGraphScript = document.createElement('script'); deviceGraphScript.setAttribute('src', '//assets.bounceexchange.com/assets/smart-tag/versioned/cjs_min_3a843477d8e318f67237a66d0a58c542.js'); deviceGraphScript.setAttribute('async', 'async'); var dgAttrs = [{"Key":"id","Value":"c.js"},{"Key":"async","Value":"true"},{"Key":"data-apikey","Value":"2^HIykD"},{"Key":"data-cb","Value":"bouncex.dg.initPostDeviceGraph"},{"Key":"data-bx","Value":"1"},{"Key":"data-gm","Value":"1"},{"Key":"data-fire","Value":"1"}]; if (dgAttrs) { for (var i = 0; i < dgAttrs.length; i++) { deviceGraphScript.setAttribute(dgAttrs[i].Key, dgAttrs[i].Value); } } document.body.appendChild(deviceGraphScript); bouncex.initializeTag = function() {}; }; document.body.appendChild(runtime); } } if (document.readyState === "loading") { document.addEventListener("DOMContentLoaded", bxBootstrap); } else { bxBootstrap(); }})();