(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":4332,"name":"Thistle","cookie_name":"bounceClientVisit4332","domain":"thistle.co","ct":"fp_local_storage","ally":0,"ei":0,"tcjs":"","cjs":"bouncex.infoStore = {\n sessionStorageIdentifier: 'bxInfoStore',\n set: function(data) {\n var hashedData = bouncex.lz.compressToURI(JSON.stringify(data));\n try {\n sessionStorage.setItem(this.sessionStorageIdentifier, hashedData);\n } catch(e) {\n bouncex.err('session storage failure');\n }\n },\n \n get: function() {\n var info = sessionStorage.getItem(this.sessionStorageIdentifier);\n return info ? JSON.parse(bouncex.lz.decompressFromURI(info)) : '';\n },\n \n infoIsStored: function() {\n return !!sessionStorage.getItem(this.sessionStorageIdentifier);\n },\n \n populateFields: function(fields) {\n if (!this.infoIsStored()) return;\n \n var data = this.get();\n for (var field in fields) {\n if (fields.hasOwnProperty(field)) {\n fields[field].val(data[field]);\n }\n }\n }\n};\n\nbouncex.infoStore.populateFields({\n email: jQuery('#id_email')\n});","force_https":false,"waypoints":false,"content_width":900,"gai":"UA-50791920-3","swids":"","sd":0,"ljq":"auto","campaign_id":0,"is_preview":false,"aco":{"first_party_limit":"3500","local_storage":"1"},"cmp":{"gdpr":0,"gmp":0,"whitelist_check":0},"burls":[],"ple":false,"fbe":true,"mas":2,"map":1,"gar":true,"ete":1,"ettm":false,"etjs":"var BROWSE_URLS = [\n '/menu/',\n '/next-weeks-menu/',\n '/cold-pressed-juices/',\n '/plant-based-bites/',\n '/how/',\n '/nutrition/',\n '/learn/sustainability',\n '/about/',\n ],\n PLAN_URLS = [\n '/order-thistle/build-plan/',\n '/order/customize-subscription/',\n '/order/protein-preference/',\n '/order/allergen-preference/',\n '/order/upcoming-menu/',\n ],\n CART_URLS = ['/order/delivery-info/', '/order-thistle/delivery-info/', '/order-thistle/credit/'];\n\nif (window.location.hostname === 'www.thistle.co') {\n var currentUrl = bouncex.utils.url.allowParams();\n\n switch(true) {\n case checkAbandonment(currentUrl, BROWSE_URLS):\n bouncex.push(['browse abandonment', {}]);\n break;\n case checkAbandonment(currentUrl, PLAN_URLS):\n bouncex.push(['select plan', {}]);\n break;\n case checkAbandonment(currentUrl, CART_URLS):\n bouncex.push(['add to cart', {}]);\n break;\n default:\n break;\n }\n\n trackLoggedInUser();\n trackInvalidZipcode();\n}\n\nfunction trackInvalidZipcode(){\n bouncex.et.onVisible('.MuiPaper-root.MuiAlert-root.MuiAlert-standardError.jss4.MuiPaper-elevation0', function(){\n bouncex.push(['invalid_zipcode', {}]);\n });\n}\n\nfunction checkAbandonment(url, urlsArr) {\n for (var i = 0; i < urlsArr.length; i++) {\n if (url.indexOf(urlsArr[i]) > -1) {\n return true;\n }\n }\n return false;\n}\n\nfunction trackLoggedInUser() {\n if (bouncex.vars.logged_in && bouncex.vars.logged_in_identified === false) {\n var userEmail = getLoggedInEmail();\n if (userEmail && bouncex.utils.validate.email(userEmail)) {\n bouncex.push([\n 'user',\n {\n email: userEmail,\n source: 'LoggedIn',\n },\n ]);\n bouncex.setv('logged_in_identified', true);\n }\n }\n}\n\nfunction getLoggedInEmail() {\n var scriptData = jQuery('script[type=\"text/javascript\"]')\n .filter(function () {\n return jQuery(this).text().indexOf('zE.identify') > -1;\n })\n .text();\n\n if (scriptData) {\n return scriptData.split('email: \\'')[1].split('\\',')[0];\n }\n\n return bouncex.utils.getNestedProp('window.U_EM_ADD', '');\n}\n","dge":true,"bxidLoadFirst":false,"pie":true,"cme":true,"gbi_enabled":0,"bpush":false,"pt":{"cart":{"testmode":true,"val":[[{"activation":"js","prop":"","prop2":"","prop3":"","val":""}]]},"category":{"testmode":false,"val":[[{"activation":"js","prop":"","prop2":"","prop3":"","val":"document.querySelectorAll('.meal').length > 0 || document.querySelectorAll('.juice-box').length > 0;\n"}]]},"checkout":{"testmode":false,"val":[[{"activation":"current_page_url","prop":"contains","prop2":"","prop3":"","val":"/delivery-info"},{"activation":"current_page_url","prop":"contains","prop2":"","prop3":"","val":"/credit"}],[{"activation":"current_page_url","prop":"not_contains","prop2":"","prop3":"","val":"localhost:8000"}]]},"home":{"testmode":false,"val":[[{"activation":"js","prop":"","prop2":"","prop3":"","val":"document.querySelectorAll('.landing-page').length > 0;\n"}],[{"activation":"current_page_url","prop":"not_contains","prop2":"","prop3":"","val":"localhost:"}],[{"activation":"current_page_url","prop":"not_contains","prop2":"","prop3":"","val":".translate.goog"}],[{"activation":"current_page_url","prop":"not_contains","prop2":"","prop3":"","val":"thistle-web-staging-primary.herokuapp.com"}]]},"product":{"testmode":false,"val":[[{"activation":"current_page_url","prop":"contains","prop2":"","prop3":"","val":"/build-plan"}]]},"search":{"testmode":true,"val":[[{"activation":"js","prop":"","prop2":"","prop3":"","val":""}]]}},"els":{"blank_site_element":""},"vars":[{"name":"logged_in","polling":"all","persist":"no","page_types":[],"testmode":false,"default":"false","code":"(function() {\n var dataLayer = bouncex.utils.getNestedProp('window.dataLayer', []);\n\n for (var i = 0; i < dataLayer.length; i++) {\n if (dataLayer[i].userId) {\n return true;\n }\n }\n\n return jQuery('.logout').length > 0;\n})();","trigger":""},{"name":"ever_logged_in","polling":"none","persist":"permanent","page_types":[],"testmode":false,"default":"false","code":"bouncex.vars.logged_in || null;","trigger":""},{"name":"cart_qty","polling":"all","persist":"no","page_types":[],"testmode":true,"default":"0","code":"","trigger":""},{"name":"cart_value","polling":"all","persist":"no","page_types":[],"testmode":true,"default":"0","code":"","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":"all","persist":"permanent","page_types":[],"testmode":true,"default":"false","code":"(function() {\n if (window.location.pathname.indexOf('order-thistle') > -1) {\n return jQuery('#id_email').length === 0 ? true : null;\n } else if (window.location.pathname === '/login/') {\n return null;\n }\n return jQuery('.footer_email_collection:visible').length === 0;\n})();","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":true,"default":"false","code":"null;","trigger":"pageload"},{"name":"cookie_modal_present","polling":"all","persist":"no","page_types":[],"testmode":true,"default":"false","code":"null;","trigger":"pageload"},{"name":"logged_in_identified","polling":"none","persist":"visit","page_types":[],"testmode":false,"default":"false","code":"null;","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":1,"mibcx":1,"te":1,"cart_rep":{"get":"","set":""},"ulpj":{"bxid":"espemailid"},"cus":"","miw_exclude":"'.recipient-row input[type=email]'","enabled":1},"etjson":null,"osre":true,"osru":"osr.bounceexchange.com/v1/osr/items","checkDfp":false,"gamNetwork":"","spa":0,"spatm":1,"preinit_cjs":"var segments = {\n /* PROPERTIES */\n testMode: false,\n interceptEnabled: true,\n \n useIntercept: function() {\n if (!this.interceptEnabled) {\n return;\n }\n bouncex.utils.shqInterceptEvent = {\n checkout: function(){\n _shq.push(['onCheckout']);\n },\n cartAdd: true\n };\n },\n\n captureCat: function(){\n var catName = document.querySelector('div#menu-container')?.dataset?.context;\n if(!!catName){\n _shq.push(['onCategory', { \n pagetype: 'category', \n catName: catName, \n catId: catName \n }]);\n }\n },\n captureProd: function(){\n var checker = bouncex.setInterval2(function(){\n if(document.querySelector('div.meal-modal')){\n var mealId = document.querySelector('.recipe-name') ? document.querySelector('.recipe-name').textContent : '';\n if (mealId) {\n clearInterval(checker);\n _shq.push(['onProductView', {\n pageType: 'product',\n productId: mealId\n }]);\n }\n }\n },300);\n \n },\n captureATC: function(){\n var checker = bouncex.setInterval2(function(){\n var meals = document.querySelectorAll('[data-testid=\"meal-card\"]');\n meals.forEach(function(e){\n var prodQty = +e.querySelector('.quantityDisplay')?.textContent;\n if(!!prodQty && prodQty > 0){\n var prodPrice = e.querySelector('[data-testid=\"meal-price\"]')?.textContent.replace(/[^0-9.]/g, ''),\n prodId = e.querySelector('[data-testid=\"meal-name\"]')?.textContent,\n atcBtn = document.querySelector('[data-testid=\"customize-delivery-save\"]');\n if(!!prodPrice && !!prodId && atcBtn){\n clearInterval(checker);\n atcBtn.addEventListener('click', function(){\n _shq.push(['onCartAdd', { \n CartId: null, \n Items: [{\n ProductId: prodId, \n UnitPrice: prodPrice, \n Quantity: prodQty,\n }],\n Total: +prodPrice * +prodQty\n }]);\n });\n }\n }\n });\n },300);\n },\n\n /* Initialize Segments Tracking */\n init: function() {\n // test mode\n if (this.testMode && !bouncex.testmode.bxdev) return;\n // attach object to window & bouncex.utils\n if (window.bouncex.utils) bouncex.utils.segments = this;\n this.captureCat();\n this.captureProd();\n this.captureATC();\n this.useIntercept();\n // initialize intercept and mirror, comment out if not needed\n }\n}\n\nsegments.init();\n\n//To use dlFuncs call this in Event Tracking\n//bouncex.utils.segments.useDLWatcher();","crs":{"integrations":null,"pageCount":null},"mat":0,"math":0,"cpnu":"coupons.bounceexchange.com","dfpcms":0,"sms":{"optm":"Hit 'Send' to sign-up for automated, recurring Thistle mktg txts (like cart reminders) to this #, per terms.","eventSharing":true,"shqId":"7wjiswpckd-1","enabled":1},"pde":true,"fmc":["US","CA"],"fme":true,"fmx":".recipient-row input[type=email]","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":"367243307","ga4_measurement_id":"G-NCFP70SXW8"} ; 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: 0 }; bouncex.assets = {"ads":"060c82010be32c8940e5ef98bcf77a22","creativesBaseStyles":"a53944a2","gpsAuction":"1375a7b38c31e98d14fe7f396b72da14","inbox":"02aca5df0e176b8810a86da97ac05424","onsite":"0e56ab6ba004ee080ce3deb3edae35e9","sms":"e39203556bab2366e56296ce42e974a7","websdk":"0704dae1eb637cbeb4a847506058402d"}; bouncex.push = function(pushData) { bouncex.pushedData.push(pushData); } var runtime = document.createElement('script'); runtime.setAttribute('src', '//assets.bounceexchange.com/assets/smart-tag/versioned/runtime_6459738026535cda4232dc813c61447d.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_e6aef002e162dc3c3a947c6f327cd93d.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); } window._shq = window._shq || []; var eventSharingCartridge = document.createElement('script'); eventSharingCartridge.setAttribute('src', '//assets.bounceexchange.com/assets/smart-tag/versioned/wknd_audiences_2648fa8509e4b3a98a2790bb8171ddc1.js'); eventSharingCartridge.setAttribute('async', 'async'); document.body.appendChild(eventSharingCartridge); } if (document.readyState === "loading") { document.addEventListener("DOMContentLoaded", bxBootstrap); } else { bxBootstrap(); }})();