(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":3873,"name":"BrainMD","cookie_name":"bounceClientVisit3873","domain":"brainmd.com","ct":"multi_cookie","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\nif (bouncex.testmode.bxdev) {\n\tvar bxGa = bouncex.report_ga;\n\tbouncex.report_ga = function(action, label, bypass) {\n\t\tvar submitType = label.split(' - ').shift()\n\t\t\n\t\tif (action === 'submission') {\n\t\t\tif (submitType === 'EMAIL' || submitType === 'TEXT') {\n\t\t\t\tbxGa(action, label, bypass);\n\t\t\t}\n\t\t} else {\n\t\t\tbxGa(action, label, bypass);\n\t\t}\n\t};\n}","force_https":false,"waypoints":false,"content_width":900,"gai":"UA-22945161-1","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,"ffs":"DISABLE_IOS_ABSOLUTE","mas":2,"map":1,"gar":true,"ete":1,"ettm":false,"etjs":"bouncex.log('init123>>')\r\n// *----* ITEM TRACKING *----* //\r\n\r\nvar BRAIN_MD_DOMAIN = 'https://brainmd.com/';\r\n\r\n// ---- HELPERS ---- //\r\n// SHQ - Helper function to filter GTM dataLayer for specific events\r\nfunction getFilteredDL(dl, event) {\r\n var lastEvent = [];\r\n if (dl && dl.length > 0) {\r\n for (var i = 0; i < dl.length; i++) {\r\n if (dl[i].hasOwnProperty('event') && dl[i].event === event) { lastEvent.push(dl[i]); }\r\n }\r\n return lastEvent && lastEvent.length > 0 ? lastEvent.pop() : false;\r\n }\r\n}\r\n\r\nfunction getUrl() {\r\n\treturn bouncex.utils.url.allowParams();\r\n}\r\n\r\nfunction isValidDomain(){\r\n\tvar currentUrl = getUrl();\r\n\r\n\treturn currentUrl.indexOf(BRAIN_MD_DOMAIN) > -1 && !currentUrl.includes('trial');\r\n}\r\n\r\nfunction isEnUs(){\r\n return jQuery('html').attr('lang') === 'en';\r\n}\r\n\r\nfunction getIdFromUrl(url) {\r\n url = url || '';\r\n\r\n if (url === 'https://brainmd.com/catalog/product/view/_ignore_category/1/id/657/s/brain-health-coaching-certification-course/') {\r\n return 'brain-health-coaching-certification-course';\r\n } else {\r\n return url.split('/').pop();\r\n }\r\n}\r\n\r\nfunction isValidCoursePage(){\r\n return jQuery('.field.configurable.required').length === 0;\r\n}\r\n\r\n// ---- ITEM META DATA ---- //\r\n\r\nfunction getItemId() {\r\n var url = getItemUrl();\r\n\r\n\treturn getIdFromUrl(url);\r\n}\r\n\r\nfunction getItemUrl() {\r\n\treturn jQuery('link[rel=\"canonical\"]').attr('href');\r\n}\r\n\r\nfunction getItemCopy() {\r\n\treturn jQuery('.page-title').text().trim();\r\n}\r\n\r\nfunction getItemCategory() {\r\n\tvar categoryBreadcrumb = jQuery('li.item.category').eq(0).text().trim();\r\n\tvar categoryClass = jQuery('body[data-container=\"body\"]').attr('class') || '';\r\n\r\n\tif (!categoryBreadcrumb && !categoryClass){\r\n\t return 'Brain MD';\r\n\t}\r\n\r\n return categoryBreadcrumb || categoryClass.split(' ').shift();\r\n}\r\n\r\nfunction getItemImage() {\r\n\tvar itemImage = jQuery('meta[property=\"og:image\"]').attr('content') || '';\r\n\r\n if (itemImage.indexOf('placeholder') > -1){\r\n itemImage = jQuery('.fotorama__img').attr('src');\r\n }\r\n\r\n return itemImage;\r\n}\r\n\r\nfunction itemInStock() {\r\n return jQuery('.product-info-main button.tocart').length > 0;\r\n}\r\n\r\nfunction isValidItem() {\r\n\tvar itemId = getItemId();\r\n\treturn itemId || false;\r\n}\r\n\r\n// SHQ - Collecting productId for shq_id to match product feed\r\nfunction getShqProdId() {\r\n var pdpObj = getFilteredDL(window.dataLayer, 'productDetail');\r\n var shqProdId = bouncex.utils.getNestedProp('ecommerce.detail.products[0].id', null, pdpObj);\r\n return shqProdId;\r\n}\r\n\r\n// SHQ - Collecting productId during add to cart for shq_id to match product feed\r\nfunction shqAddToCart() {\r\n var filterDL;\r\n bouncex.et.onTrue(function(){\r\n filterDL = getFilteredDL(window.dataLayer, 'addToCart');\r\n return !!filterDL;\r\n }, function(){\r\n var shqProdId = bouncex.utils.getNestedProp('ecommerce.add.products[0].id', null, filterDL);\r\n if (shqProdId) {\r\n _shq.push([ 'onCartAdd', {\r\n CartId: null,\r\n Items: [{\r\n ProductId: shqProdId,\r\n UnitPrice: null,\r\n Quantity: 1\r\n }],\r\n Total: null\r\n }]);\r\n }\r\n }, 10);\r\n}\r\n\r\nfunction getItem() {\r\n\treturn {\r\n\t\tid : getItemId(),\r\n\t\tcopy: getItemCopy(),\r\n\t\tcategory : getItemCategory(),\r\n\t\turl : getItemUrl(),\r\n\t\timageurl : getItemImage(),\r\n\t\tinstock : itemInStock(),\r\n\t\tshq_id: getShqProdId(),\r\n\t};\r\n}\r\n\r\nfunction viewItem(itemId){\r\n bouncex.push(['view item', {\r\n 'item:id': itemId,\r\n 'item:shq_id': getShqProdId()\r\n }]);\r\n\r\n}\r\n\r\nfunction fireItemEvents(){\r\n\tvar item = getItem();\r\n\r\n\tbouncex.push(['item', item]);\r\n\tviewItem(item.id);\r\n}\r\n\r\n// ---- CATEGORY META DATA ---- //\r\n\r\nfunction getCategoryPageTitle(){\r\n\treturn jQuery('ul.items:first li').last().text().trim();\r\n}\r\n\r\nfunction getCategoryIds(){\r\n return jQuery('.product.product-item-photo').map(function () {\r\n var itemUrl = jQuery(this).attr('href');\r\n var itemId = getIdFromUrl(itemUrl);\r\n\r\n if (itemId) {\r\n return itemId;\r\n }\r\n\r\n }).toArray().join(',');\r\n}\r\n\r\nfunction getCategoryObj(){\r\n\treturn {\r\n 'page:title' : getCategoryPageTitle(),\r\n 'page:url': window.location.href,\r\n 'items:ids': getCategoryIds()\r\n };\r\n}\r\n\r\n// ---- CART TRACKING ---- //\r\n\r\nbouncex.et.cart.init({\r\n replenish: function () {},\r\n replenishmentType: 'single'\r\n});\r\n\r\nfunction addToCart(){\r\n bouncex.et.on(jQuery(document), 'click.bx', function(e){\r\n var itemId = getItemId();\r\n\r\n if (bouncex.website.pts === 'category'){\r\n var itemUrl = jQuery(e.target).parentsUntil('.product-item').find('a.product-item-photo').attr('href');\r\n\r\n itemId = getIdFromUrl(itemUrl);\r\n }\r\n\r\n fireATC(itemId);\r\n\r\n if (jQuery('#option-subscribe').is(':checked')) {\r\n bouncex.push(['view_subscription', {'item:id':itemId}]);\r\n }\r\n shqAddToCart();\r\n }, '#product-addtocart-button');\r\n}\r\n\r\n\r\n\r\nfunction recommendedATC(){\r\n if (bouncex.website.pts == \"product\"){\r\n bouncex.on(jQuery(\".action.tocart.primary\"),'click.bx', function() {\r\n jQuery(this).off('click.bx');\r\n var itemId = jQuery(this).closest(\".product-item,.product-item-head\").find(\".product-item-info a,.product-item-photo a\").attr(\"href\").split(\"/\").pop();\r\n \r\n if(itemId){\r\n fireATC(itemId)\r\n }\r\n \r\n })\r\n \r\n }\r\n}\r\n\r\nfunction fireATC(itemId) {\r\n // using shq_bypass to prevent this from being passed to shq so we can collect the add to cart productId outside of Wknd add to cart\r\n bouncex.setVar('cart', true);\r\n bouncex.push(['add to cart', {'item:id':itemId, 'shq:shq_bypass':true}]);\r\n}\r\n\r\n/*function emptyCart() {\r\n if (bouncex.website.pts === 'cart' && bouncex.vars.cart) {\r\n bouncex.et.onVisible('.cart-empty', function () {\r\n bouncex.push(['empty_cart']);\r\n bouncex.setVar('cart', false);\r\n });\r\n }\r\n}*/\r\nfunction emptyCart() {\r\n bouncex.et.onVarChange('cart_qty', function (oldVal, newVal) {\r\n if (bouncex.vars.cart && newVal === 0 && oldVal > 0) {\r\n bouncex.push(['empty_cart']);\r\n bouncex.setVar('cart', false);\r\n }\r\n });\r\n}\r\n\r\n// ---- USER TRACKING ---- //\r\n\r\nfunction getLoggedInUserEmail(){\r\n return jQuery('.box-content').eq(0).text().trim().split(' ').pop() || \r\n (window.checkoutConfig && window.checkoutConfig.customerData && window.checkoutConfig.customerData.email);\r\n\r\n}\r\n\r\n// ---- INITIALIZE EVENTS ---- //\r\nfunction initializeItemEvents(){\r\n\tif (bouncex.website.pts === 'product' && isValidCoursePage()){\r\n\t\tbouncex.et.onTrue(isValidItem, fireItemEvents, 10);\r\n\t}\r\n}\r\n\r\nfunction initializeCategoryEvents(){\r\n var categoryObj;\r\n\r\n if (bouncex.website.pts === 'category' || bouncex.website.pts === 'search'){\r\n \tcategoryObj = getCategoryObj();\r\n\r\n \tif (categoryObj['items:ids'].length){\r\n \t\tbouncex.push(['view category', categoryObj]);\r\n }\r\n\r\n quickATC();\r\n\t}\r\n}\r\n\r\nfunction quickATC(){\r\n var itemId;\r\n\r\n bouncex.et.on(jQuery(document), 'click.bx', function(e){\r\n itemId = getIdFromUrl(jQuery(this).parents('.product-item').find('a.product-item-link').attr('href'));\r\n\r\n if (itemId) {\r\n fireATC(itemId);\r\n }\r\n }, 'button[title=\"Add to Cart\"]');\r\n}\r\n\r\nfunction initializeCartEvents(){\r\n addToCart();\r\n recommendedATC();\r\n emptyCart();\r\n}\r\n\r\nfunction fireLoggedInUser() {\r\n var userEmail;\r\n\r\n bouncex.et.onTrue(\r\n function () {\r\n userEmail = getLoggedInUserEmail();\r\n return bouncex.utils.validate.email(userEmail);\r\n },\r\n function () {\r\n bouncex.push([\r\n 'user',\r\n {\r\n 'email': userEmail,\r\n 'source': 'LoggedIn'\r\n }\r\n ]);\r\n bouncex.setVar('logged_in_identified', true);\r\n },\r\n 5\r\n );\r\n}\r\n\r\nfunction initializeLoggedInUser() {\r\n if (bouncex.vars.logged_in && !bouncex.vars.logged_in_identified) {\r\n fireLoggedInUser();\r\n return;\r\n }\r\n\r\n bouncex.et.onVarChange('logged_in', function (oldVal, newVal) {\r\n if (newVal && !bouncex.vars.logged_in_identified) {\r\n fireLoggedInUser();\r\n }\r\n });\r\n}\r\n\r\n\r\nif (isValidDomain() && isEnUs()) {\r\n\tinitializeLoggedInUser();\r\n\tinitializeItemEvents();\r\n\tinitializeCartEvents();\r\n\tinitializeCategoryEvents();\r\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":"/cart"}]]},"category":{"testmode":false,"val":[[{"activation":"js","prop":"","prop2":"","prop3":"","val":"document.querySelectorAll('.catalog-category-view').length > 0;"}],[{"activation":"js","prop":"","prop2":"","prop3":"","val":"document.querySelectorAll('div.products-grid').length > 0;"}]]},"checkout":{"testmode":false,"val":[[{"activation":"current_page_url","prop":"contains","prop2":"","prop3":"","val":"/checkout"}],[{"activation":"current_page_url","prop":"not_contains","prop2":"","prop3":"","val":"/cart"}]]},"home":{"testmode":false,"val":[[{"activation":"js","prop":"","prop2":"","prop3":"","val":"document.querySelectorAll('body.cms-home').length > 0;"}]]},"product":{"testmode":false,"val":[[{"activation":"js","prop":"","prop2":"","prop3":"","val":"document.querySelectorAll('.catalog-product-view').length > 0;"}]]},"search":{"testmode":false,"val":[[{"activation":"current_page_url","prop":"contains","prop2":"","prop3":"","val":"/result/?"}]]}},"els":{"CART - Checkout Button":"","CART - Promo Code Apply Button":"","CART - Promo Code Box":"","CAT - Product Grid Image":"","CAT - Quickview Box":"","CAT-AddtoCartButton":"","CAT-QuickviewAddtoCart":"","Footer":"","Navigation bar":"","PDP - Add to Cart Button":"","PDP - Color Option":"","PDP - Hero Image":"","PDP - Product Name":"","PDP - Product Price":"","PDP - Quantity Option":"","PDP - Review Stars":"","PDP - Size Option":"","PDP - Thumbnail Image":"","SEARCH - Product Grid Image":""},"vars":[{"name":"logged_in","polling":"all","persist":"no","page_types":[],"testmode":false,"default":"false","code":"(function() {\n var cacheStorage = bouncex.utils.getNestedProp([\"mage-cache-storage\"], '', localStorage);\n var parsedData;\n var customerName = '';\n \n\t/* check that what we need to parse exists */\n if (cacheStorage.length > 0) {\n \tparsedData = JSON.parse(cacheStorage);\n customerName = bouncex.utils.getNestedProp('customer.fullname', '', parsedData);\n }\n \n /* customerName exists for logged_in user */\n if(customerName.length === 0){bouncex.setVar('logged_in_identified', false);}\n return customerName.length > 0;\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":"(function() {\n \n if ((jQuery('span.counter-number').text() === '' && jQuery(\".block-minicart:visible\").length) || window.location.href.indexOf('/logoutSuccess') > -1 || jQuery('div.cart-empty:contains(\"no items\")').length > 0) {\n return 0;\n }\n else if (jQuery('span.counter-number').length > 0) {\n /* takes a few seconds for the cart_qty to load, so put in null logic */\n return Number(jQuery('span.counter-number').eq(0).text().replace(/[^0-9]/g, '')) || null;\n }\n return null;\n})();","trigger":""},{"name":"cart_value","polling":"all","persist":"visit","page_types":[],"testmode":false,"default":"0","code":"(function() {\n if (jQuery('span.counter-number').text() === '0' || window.location.href.indexOf('/logoutSuccess') > -1 || jQuery('div.cart-empty:contains(\"no items\")').length > 0) {\n return 0;\n }\n if (jQuery('.price-wrapper span.price').length > 0) {\n return Number(jQuery('span[data-bind*=\"subtotal\"] span.price:eq(0)').text().replace(/[^0-9.]/g, '')) || null;\n }\n return null;\n})();","trigger":""},{"name":"prod_price","polling":"all","persist":"no","page_types":[],"testmode":false,"default":"false","code":"bouncex.website.pts === 'product' && Number(jQuery('.field input[name*=\"option\"]:checked').siblings('label[for*=\"option\"]').children('.option-price').text().replace(/[^0-9.]/g, '') || jQuery('span[data-price-type=\"finalPrice\"] span.price:eq(0)').text().replace(/[^0-9.]/g, ''));","trigger":""},{"name":"prod_name","polling":"none","persist":"no","page_types":[],"testmode":false,"default":"false","code":"bouncex.website.pts === 'product' && jQuery('.page-title').text().trim();","trigger":""},{"name":"in_stock","polling":"all","persist":"no","page_types":[],"testmode":false,"default":"false","code":"bouncex.website.pts === 'product' && jQuery('.unavailable:visible:contains(\"Out of stock\")').length === 0;","trigger":""},{"name":"submitted_onsite","polling":"none","persist":"permanent","page_types":[],"testmode":false,"default":"false","code":"jQuery('.success:visible:contains(\"subscription\")').length > 0 || null;","trigger":""},{"name":"item_id_product","polling":"none","persist":"no","page_types":["product"],"testmode":true,"default":"false","code":"","trigger":""},{"name":"item_id_quickview","polling":"none","persist":"no","page_types":[],"testmode":true,"default":"false","code":"","trigger":"event"},{"name":"item_id_hover","polling":"none","persist":"no","page_types":[],"testmode":true,"default":"false","code":"","trigger":"event"},{"name":"items_ids","polling":"none","persist":"no","page_types":["category","search"],"testmode":true,"default":"false","code":"","trigger":""},{"name":"item_url","polling":"none","persist":"no","page_types":["product"],"testmode":true,"default":"false","code":"","trigger":""},{"name":"item_image_url","polling":"none","persist":"no","page_types":["product"],"testmode":true,"default":"false","code":"","trigger":""},{"name":"item_category","polling":"none","persist":"no","page_types":["product"],"testmode":true,"default":"false","code":"","trigger":""},{"name":"item_price","polling":"none","persist":"no","page_types":["product"],"testmode":true,"default":"false","code":"","trigger":""},{"name":"item_in_stock","polling":"none","persist":"no","page_types":["product"],"testmode":true,"default":"false","code":"","trigger":""},{"name":"page_url","polling":"none","persist":"no","page_types":["category","search"],"testmode":true,"default":"false","code":"","trigger":""},{"name":"page_title","polling":"none","persist":"no","page_types":["category"],"testmode":true,"default":"false","code":"","trigger":""},{"name":"item_copy","polling":"none","persist":"no","page_types":["product"],"testmode":true,"default":"false","code":"","trigger":"pageload"},{"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":"logged_in_identified","polling":"none","persist":"visit","page_types":[],"testmode":false,"default":"false","code":"null;","trigger":"pageload"},{"name":"has_excluded_class","polling":"all","persist":"visit","page_types":[],"testmode":false,"default":"false","code":"(function(){\r\n var found = false;\r\n var list = [\"Memory Master Course - Premium\", \"Change Your Brain Masters - Premium\", \"Brain Warrior\\'s Way - Premium\", \"Brain Thrive by 25 - Premium\", \"Healing ADD at Home - Premium\", \"Overcoming Insomnia Course - Premium\", \"Autism: A New Way Forward - Premium\"] ;\r\n if(bouncex.website.pts === \"checkout\"){\r\n return null\r\n }\r\n if(bouncex.website.pts != \"cart\" && jQuery('#mini-cart .product-item').length > 0){\r\n jQuery('#mini-cart .product-item').map(function(_, b){\r\n if(list.indexOf(jQuery(b).find('.product-item-name').text().trim()) > -1){\r\n found = true;\r\n }\r\n });\r\n return found;\r\n } else if(bouncex.website.pts === \"cart\"){\r\n jQuery('#shopping-cart-table .cart.item').map(function(_, b){\r\n if(list.indexOf(jQuery(b).find('.product-item-name').text().trim()) > -1){\r\n found = true;\r\n }\r\n });\r\n }\r\n return found\r\n})();","trigger":"pageload"},{"name":"subscription_price_diff","polling":"none","persist":"no","page_types":["product"],"testmode":false,"default":"false","code":"(function() {\n var purchase = jQuery('#option-label_onetime .option-price');\n var subscription = jQuery('#option-label_subscription .option-price');\n var diff = 0;\n if (purchase.length > 0 && subscription.length > 0) {\n diff = Number(purchase.text().replace(/[^0-9.]/g, '')) - Number(subscription.text().replace(/[^0-9.]/g, ''));\n return Number((Math.round(diff * 100) / 100).toFixed(2));\n }\n return diff;\n})();","trigger":"pageload"},{"name":"subscription_price_visible","polling":"none","persist":"no","page_types":["product"],"testmode":false,"default":"false","code":"jQuery('.subscribe-option .option-price').length > 0;","trigger":"pageload"},{"name":"subscription_in_cart","polling":"all","persist":"visit","page_types":[],"testmode":false,"default":"false","code":"(function(){\r\n if(bouncex.website.pts === \"checkout\"){\r\n return null;\r\n }\r\n return jQuery('.minicart-items-wrapper .product-item-details .product-options-list:contains(\"Regular Delivery\")').length > 0\r\n})()","trigger":"pageload"},{"name":"article_topic","polling":"all","persist":"no","page_types":[],"testmode":false,"default":"false","code":"(function() {\n var category = jQuery('h3.entry-title').text().split(':').pop().trim().toLowerCase() || jQuery(\"img[id*=batBeacon]\").first().attr(\"src\") || \"\";\n if (!(bouncex.utils.url.allowParams().indexOf('blog') > -1)) {\n return false;\n }\n\n if (category.indexOf(\"sleep\") > -1) {\n return \"Sleep\";\n }\n if (category.indexOf(\"memory\") > -1) {\n return \"Memory\";\n }\n if (category.indexOf(\"focus\") > -1) {\n return \"Focus\";\n }\n if (category.indexOf(\"mood\") > -1) {\n return \"Mood\";\n }\n if (category.indexOf(\"weight\") > -1 || category.indexOf(\"nutrition\") > -1) {\n return \"Nutrition\";\n }\n if (category.indexOf(\"family\") > -1) {\n return \"Family\";\n }\n return \"Brain Health\"\n}());","trigger":"pageload"},{"name":"subscription_radio_button","polling":"all","persist":"no","page_types":[],"testmode":false,"default":"true","code":"jQuery('#option_subscription, #option-subscribe').first().is(':checked');","trigger":"pageload"},{"name":"brain_type","polling":"all","persist":"no","page_types":[],"testmode":false,"default":"false","code":"bouncex.utils.url.allowParams().indexOf('/result') > -1 ? jQuery('.bt').first().text() : false;","trigger":"pageload"},{"name":"one_time_radio_checked","polling":"all","persist":"no","page_types":[],"testmode":false,"default":"false","code":"jQuery('#option-onetime').length && jQuery('#option-onetime').is(':checked');","trigger":"pageload"},{"name":"page_type","polling":"none","persist":"no","page_types":[],"testmode":false,"default":"false","code":"bouncex.website.pts || null;","trigger":"pageload"},{"name":"contains_shipping","polling":"all","persist":"no","page_types":[],"testmode":false,"default":"false","code":"window.location.hash.indexOf('#shipping') > -1","trigger":"pageload"},{"name":"contains_payment","polling":"all","persist":"no","page_types":[],"testmode":false,"default":"false","code":"window.location.hash.indexOf('#payment') > -1","trigger":"pageload"},{"name":"cart","polling":"none","persist":"permanent","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":"","enabled":1},"etjson":null,"osre":true,"osru":"osr.bounceexchange.com/v1/osr/items","checkDfp":false,"gamNetwork":"","spa":1,"spatm":0,"preinit_cjs":" SinglePageApp.setCustomParams({\n currentPageIdentifier: function () {\n var pathNameHash = window.location.pathname + window.location.hash;\n if (pathNameHash.indexOf('/checkout/#payment') > -1 || pathNameHash.indexOf('/checkout/#shipping') > -1) {\n return true;\n }\n return true;\n },\n shouldCheckSpa: function() {\n return bouncex.testmode.bxdev ? window.location.hash.indexOf('#payment') > -1 : true\n },\n});\n\n\n/* --- AUDIENCE HELPER FUNCTIONS --- */\nfunction mapProdArry(objSrc, objStringPath, shqEventName) {\n var itemsArry = bouncex.utils.getNestedProp(objStringPath, [], objSrc).map(function(e) {\n var prodId = bouncex.utils.getNestedProp('id', '', e),\n prodPrice = bouncex.utils.getNestedProp('price', '', e),\n prodQty = bouncex.utils.getNestedProp('quantity', '', e),\n isSub = bouncex.utils.getNestedProp('is_subscription', '', e),\n subInterval = bouncex.utils.getNestedProp('subscription_interval', '', e);\n\n if (shqEventName === 'addToCart' && !!prodId && !!prodPrice && !!prodQty) {\n return {\n ProductId: prodId,\n UnitPrice: +prodPrice,\n Quantity: +prodQty\n }\n }\n if (shqEventName === 'purchase' && !!prodId && !!prodPrice && !!prodQty) {\n return {\n productId: prodId,\n price: +prodPrice,\n qty: +prodQty\n }\n }\n if (shqEventName === 'customProduct' && !!prodId && !!prodQty && !!isSub && !!subInterval) {\n return {\n productId_scraped: prodId,\n customproductid: prodId,\n issubscription: isSub,\n subscription_interval: subInterval,\n subscription_quantity: prodQty\n }\n }\n });\n\n if (!!itemsArry[0] && itemsArry.length > 0) {\n return itemsArry;\n }\n}\n\nlet segments = {\n /* PROPERTIES */\n testMode: false,\n interceptEnabled: false,\n mirrorEnabled: false,\n arrayObserverEnabled: false,\n /* METHODS */\n /* Intercept Events */\n useIntercept() {\n if (!this.interceptEnabled) {\n return;\n }\n bouncex.utils.shqInterceptEvent = {\n cartAdd: false,\n purchase: false\n };\n },\n /* Mirror Events */\n useMirror() {\n if (!this.mirrorEnabled) {\n return;\n }\n bouncex.utils.shqMirrorEvent = {\n pageview: function() {\n // PageView - Search\n if (bouncex.website.pts === 'search') {\n var sp = bouncex.utils.getParam('q').replace(/\\+/gi, ' ');\n \n if (!!sp) {\n _shq.push(['onSearch', {\n searchPhrase: sp\n }]);\n }\n }\n }\n };\n },\n processObserver(e) {\n while (e.length) {\n let dlObj = e.shift();\n\n // Purchase - Cusotm Product Details & Purchase\n if (dlObj.event === 'purchase') {\n var purchItem = mapProdArry(dlObj, 'ecommerce.purchase.products', dlObj.event),\n ototal = bouncex.utils.getNestedProp('ecommerce.purchase.actionField.revenue', '', dlObj),\n customProdDetail = mapProdArry(dlObj, 'ecommerce.purchase.products', 'customProduct'),\n oid = bouncex.utils.getNestedProp('ecommerce.purchase.actionField.id', '', dlObj),\n dummyId = 'no-orderid-' + Math.floor(Math.random() * 100000000);\n\n if (!!oid && !!ototal && !!purchItem && purchItem.length > 0) {\n _shq.push(['onPurchase', {\n orderItems: purchItem,\n total: +ototal,\n orderId: oid\n }]);\n \n if (!!customProdDetail && customProdDetail.length > 0) {\n _shq.push([ 'onCustomProduct', customProdDetail]);\n }\n } else {\n _shq.push(['onPurchase', {\n usebasket: true,\n total: +ototal || 0,\n orderId: oid || dummyId\n }]);\n }\n \n } \n // Add To Cart\n if (dlObj.event === 'addToCart') {\n var atcItem = mapProdArry(dlObj, 'ecommerce.add.products', dlObj.event);\n\n if (atcItem.length > 0) {\n _shq.push(['onCartAdd', {\n Items: atcItem,\n Total: atcItem[0].UnitPrice * atcItem[0].Quantity\n }]);\n }\n }\n }\n },\n arrayObserver() {\n if (!this.arrayObserverEnabled) {\n return;\n }\n bouncex.et.onTrue(\n () => {\n return bouncex.utils.getNestedProp('window._shq.loaded');\n },\n () => {\n _shq.ArrayObserver(window.dataLayer, (e) => {\n this.processObserver(e);\n }, {catchUp:true, filter: e => e.ecommerce});\n }\n );\n },\n /* Initialize Segments Tracking */\n init() {\n // test mode\n if (this.testMode && !bouncex.testmode.bxdev) return;\n // attach object to window & bouncex.utils\n if (!bouncex.utils) {\n return;\n }\n bouncex.utils.segments = this;\n // initialize intercept and mirror, comment out if not needed\n this.useIntercept();\n this.useMirror();\n this.arrayObserver();\n },\n};\n\nsegments.init();\n","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 BrainMD mktg txts (like cart reminders) to this #, per terms.","eventSharing":false,"shqId":"b1ibom9seb-1","enabled":1},"pde":true,"fmc":["US","CA"],"fme":true,"fmx":"","uid2":false,"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,"devMode":0},"ga4_property_id":"311854643","ga4_measurement_id":"G-82WQ02S9XJ","tag_state_domain":"wd.brainmd.com","tag_state_domain_enabled":false} ; 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":"ba8ae19a5bf9548f3d50df1e54121805","creativesBaseStyles":"a53944a2","gpsAuction":"bbb80866120d17013073bb6d284cbd6b","inbox":"c5ffeacd3b77d074a53f2878c1332dc9","onsite":"c05f8c5551fa6b964660ad61916291c1","sms":"e39203556bab2366e56296ce42e974a7","websdk":"9c2817e65e803cb8c86d0410c88f20c1","website_campaigns_3873":"e79d5896620241a5e25536d80898c007"}; 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'); bouncex.initializeTag = function() { var script = document.createElement('script'); script.setAttribute('src', '//assets.bounceexchange.com/assets/smart-tag/versioned/main-v2_e017b4177b2cd559863faed730560d8f.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_c84323e2726f3e99b307ab7740c6434b.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() {}; }; runtime.onload = bouncex.initializeTag; document.body.appendChild(runtime); } } if (document.readyState === "loading") { document.addEventListener("DOMContentLoaded", bxBootstrap); } else { bxBootstrap(); }})();