{"webLayers":[{"_id":"67dc35e919788e247539c150","date_filter":{"enabled":false,"from_date":null,"to_date":null},"trigger":{"include_pages":[{"url":"https://fsastore.com/hra-store","type":"contains"}],"exclude_pages":[{"url":"cpc","type":"contains"},{"url":"srsltid","type":"contains"},{"url":"paid","type":"contains"},{"url":"insiders","type":"contains"},{"url":"https://fsastore.com/cart","type":"contains"},{"url":"https://fsastore.com/checkout","type":"contains"},{"url":"https://hsastore.com/cart","type":"contains"},{"url":"https://hsastore.com/checkout","type":"contains"},{"url":"cart","type":"contains"},{"url":"checkout","type":"contains"}]},"device_target":{"type":"any"},"frequency":"once_per_visit","uses_personalization":true,"data":"","variables_target":null,"page_vars":[]},{"_id":"67e5512c25a263ac3ef1ecff","date_filter":{"enabled":false,"from_date":null,"to_date":null},"trigger":{"include_pages":[{"url":"https://fsastore.com/hra-store","type":"contains"}],"exclude_pages":[{"url":"tpa","type":"contains"},{"url":"insiders","type":"contains"},{"url":"https://fsastore.com/cart","type":"contains"},{"url":"https://fsastore.com/checkout","type":"contains"},{"url":"https://hsastore.com/cart","type":"contains"},{"url":"https://hsastore.com/checkout","type":"contains"},{"url":"cart","type":"contains"},{"url":"checkout","type":"contains"}]},"device_target":{"type":"any"},"frequency":"once_per_visit","uses_personalization":true,"data":"","variables_target":null,"page_vars":[]},{"_id":"6894ab4b81312569c91124d5","date_filter":{"enabled":false,"from_date":null,"to_date":null},"trigger":{"include_pages":[{"url":"https://hsastore.com/best-sellers","type":"contains"}],"exclude_pages":[{"url":"#test","type":"contains"},{"url":"utm_source=bloomreach\u0026utm_campaign=hsa_email_trigger_welcome-series-email-1-coupon-click\u0026utm_medium=email","type":"contains"},{"url":"utm_source=bloomreach\u0026utm_medium=email\u0026utm_campaign=hsa_email_trigger_welcome-series-email-1-coupon-click","type":"contains"},{"url":"utm_source=bloomreach\u0026utm_campaign=hsa_sms_trigger_welcome-series-sms-1-coupon-click\u0026utm_medium=sms","type":"contains"},{"url":"utm_source=bloomreach\u0026utm_medium=sms\u0026utm_campaign=hsa_sms_trigger_welcome-series-sms-1-coupon-click","type":"contains"},{"url":"WEX","type":"contains"},{"url":"Wex","type":"contains"},{"url":"wex","type":"contains"}]},"device_target":{"type":"desktop"},"frequency":"once_per_visit","uses_personalization":true,"data":"","variables_target":null,"page_vars":[]},{"_id":"68c29b19cacb3d4912315d7f","date_filter":{"enabled":false,"from_date":null,"to_date":null},"trigger":{"include_pages":[{"url":"https://hsastore.com/","type":"contains"},{"url":"https://hsastore.com?","type":"contains"},{"url":"https://hsastore.com/?","type":"contains"}],"exclude_pages":[{"url":"insiders","type":"contains"},{"url":"https://hsastore.com/cart","type":"contains"},{"url":"https://hsastore.com/checkout","type":"contains"},{"url":"cart","type":"contains"},{"url":"checkout","type":"contains"},{"url":"mychoiceaccounts","type":"contains"},{"url":"/eligibility-quiz.html","type":"contains"},{"url":"utm_source=bloomreach\u0026utm_campaign=hsa_email_trigger_welcome-series-email-1-coupon-click\u0026utm_medium=email","type":"contains"},{"url":"utm_source=bloomreach\u0026utm_medium=email\u0026utm_campaign=hsa_email_trigger_welcome-series-email-1-coupon-click","type":"contains"},{"url":"utm_source=bloomreach\u0026utm_campaign=hsa_sms_trigger_welcome-series-sms-1-coupon-click\u0026utm_medium=sms","type":"contains"},{"url":"utm_source=bloomreach\u0026utm_medium=sms\u0026utm_campaign=hsa_sms_trigger_welcome-series-sms-1-coupon-click","type":"contains"},{"url":"/hsa-partnerships.html","type":"contains"},{"type":"regex","regex":"(.*)hsastore\\.com(.*)utm_source=WEX(.*)"},{"type":"regex","regex":"(.*)hsastore\\.com(.*)utm_source=Wex(.*)"},{"type":"regex","regex":"(.*)hsastore\\.com(.*)utm_source=wex(.*)"},{"type":"regex","regex":"(.*)hsastore\\.com(.*)utm_source=Discovery(.*)"},{"type":"regex","regex":"(.*)hsastore\\.com(.*)utm_source=discovery(.*)"},{"type":"regex","regex":"(.*)hsastore\\.com(.*)utm_source=Snyder(.*)"},{"type":"regex","regex":"(.*)hsastore\\.com(.*)utm_source=snyder(.*)"},{"url":"https://hsastore.com/learning","type":"contains"},{"url":"https://hsastore.com/telehealth.html","type":"contains"},{"url":"https://hsastore.com/telehealth-v2.html","type":"contains"},{"url":"https://hsastore.com/sms-sign-up.html","type":"contains"},{"type":"regex","regex":"(.*)hsastore\\.com(.*)utm_source=Health\\+Equity(.*)"},{"type":"regex","regex":"(.*)hsastore\\.com(.*)utm_source=health\\+equity(.*)"},{"url":"https://hsastore.com/hsa-weight-loss.html","type":"contains"}]},"device_target":{"type":"any"},"frequency":"once_per_visit","uses_personalization":true,"data":"","variables_target":null,"page_vars":[]},{"_id":"68cc31d588b6a973a15e19fa","date_filter":{"enabled":false,"from_date":1616108400,"to_date":1616281199},"trigger":{"include_pages":[{"url":"utm_campaign=fsa_email_trigger_welcome-series-email-1-coupon-click","type":"contains"},{"url":"utm_campaign=fsa_sms_trigger_welcome-series-sms-1-coupon-click","type":"contains"}],"exclude_pages":null},"device_target":{"type":"any"},"frequency":"always","uses_personalization":true,"data":"","variables_target":null,"page_vars":[]},{"_id":"68cc3273765eec5c59f6628b","date_filter":{"enabled":false,"from_date":1616108400,"to_date":1616281199},"trigger":{"include_pages":[{"url":"utm_campaign=fsa_email_trigger_welcome-series-email-1-coupon-click-20","type":"contains"},{"url":"utm_campaign=fsa_sms_trigger_welcome-series-sms-1-coupon-click-20","type":"contains"}],"exclude_pages":null},"device_target":{"type":"any"},"frequency":"always","uses_personalization":true,"data":"","variables_target":null,"page_vars":[]},{"_id":"68f2314a5d4f25555c4e41d9","date_filter":{"enabled":false,"from_date":null,"to_date":null},"trigger":{"include_pages":[{"type":"regex","regex":"(.*)hsastore\\.com(.*)utm_source=WEX(.*)"},{"type":"regex","regex":"(.*)hsastore\\.com(.*)utm_source=Wex(.*)"},{"type":"regex","regex":"(.*)hsastore\\.com(.*)utm_source=wex(.*)"},{"type":"regex","regex":"(.*)hsastore\\.com(.*)utm_source=Discovery(.*)"},{"type":"regex","regex":"(.*)hsastore\\.com(.*)utm_source=discovery(.*)"},{"type":"regex","regex":"(.*)hsastore\\.com(.*)utm_source=Snyder(.*)"},{"type":"regex","regex":"(.*)hsastore\\.com(.*)utm_source=snyder(.*)"}],"exclude_pages":[{"url":"insiders","type":"contains"},{"url":"https://hsastore.com/cart","type":"contains"},{"url":"https://hsastore.com/checkout","type":"contains"},{"url":"cart","type":"contains"},{"url":"checkout","type":"contains"},{"url":"mychoiceaccounts","type":"contains"},{"url":"https://hsastore.com/learning","type":"contains"},{"url":"https://hsastore.com/savings-center","type":"contains"},{"url":"https://hsastore.com/resource-center","type":"contains"},{"url":"/eligibility-quiz.html","type":"contains"},{"url":"utm_source=bloomreach\u0026utm_campaign=hsa_email_trigger_welcome-series-email-1-coupon-click\u0026utm_medium=email","type":"contains"},{"url":"utm_source=bloomreach\u0026utm_medium=email\u0026utm_campaign=hsa_email_trigger_welcome-series-email-1-coupon-click","type":"contains"},{"url":"utm_source=bloomreach\u0026utm_campaign=hsa_sms_trigger_welcome-series-sms-1-coupon-click\u0026utm_medium=sms","type":"contains"},{"url":"utm_source=bloomreach\u0026utm_medium=sms\u0026utm_campaign=hsa_sms_trigger_welcome-series-sms-1-coupon-click","type":"contains"},{"url":"/hsa-partnerships.html","type":"contains"},{"url":"https://hsastore.com/articles/learn-spotlight-on-discovery-benefits.html","type":"contains"}]},"device_target":{"type":"any"},"frequency":"once_per_visit","uses_personalization":true,"data":"","variables_target":null,"page_vars":[]},{"_id":"68f231531d4479822881b4dd","date_filter":{"enabled":false,"from_date":null,"to_date":null},"trigger":{"include_pages":[{"type":"regex","regex":"(.*)fsastore\\.com(.*)utm_source=WEX(.*)"},{"type":"regex","regex":"(.*)fsastore\\.com(.*)utm_source=Wex(.*)"},{"type":"regex","regex":"(.*)fsastore\\.com(.*)utm_source=wex(.*)"},{"type":"regex","regex":"(.*)fsastore\\.com(.*)utm_source=Discovery(.*)"},{"type":"regex","regex":"(.*)fsastore\\.com(.*)utm_source=discovery(.*)"},{"type":"regex","regex":"(.*)fsastore\\.com(.*)utm_source=Snyder(.*)"},{"type":"regex","regex":"(.*)fsastore\\.com(.*)utm_source=snyder(.*)"}],"exclude_pages":[{"url":"insiders","type":"contains"},{"url":"https://fsastore.com/cart","type":"contains"},{"url":"https://fsastore.com/checkout","type":"contains"},{"url":"https://fsastore.com/hra-store.html","type":"contains"},{"url":"https://fsastore.com/hra-store-spender.html","type":"contains"},{"url":"https://fsastore.com/hra.html","type":"contains"},{"url":"cart","type":"contains"},{"url":"checkout","type":"contains"},{"url":"mychoiceaccounts","type":"contains"},{"url":".com/weight-loss.html","type":"contains"},{"url":"https://fsastore.com/learning","type":"contains"},{"url":"https://fsastore.com/fsa-calculator","type":"contains"},{"url":"https://fsastore.com/savings-center","type":"contains"},{"url":"https://fsastore.com/resource-center","type":"contains"},{"url":"https://fsastore.com/articles","type":"contains"},{"url":"utm_source=bloomreach\u0026utm_campaign=fsa_email_trigger_welcome-series-email-1-coupon-click\u0026utm_medium=email","type":"contains"},{"url":"utm_source=bloomreach\u0026utm_medium=email\u0026utm_campaign=fsa_email_trigger_welcome-series-email-1-coupon-click","type":"contains"},{"url":"utm_source=bloomreach\u0026utm_campaign=fsa_sms_trigger_welcome-series-sms-1-coupon-click\u0026utm_medium=sms","type":"contains"},{"url":"utm_source=bloomreach\u0026utm_medium=sms\u0026utm_campaign=fsa_sms_trigger_welcome-series-sms-1-coupon-click","type":"contains"},{"url":"https://fsastore.com/medicine-and-treatments/vitamins-and-supplements","type":"contains"},{"url":"https://fsastore.com/medicine-and-treatments/pain-relief","type":"contains"},{"url":"https://fsastore.com/medicine-and-treatments/cold-and-allergy","type":"contains"},{"url":"https://fsastore.com/medicine-and-treatments/drug-free-pain-relief","type":"contains"},{"url":"https://fsastore.com/medicine-and-treatments/virus-preparedness","type":"contains"},{"url":"https://fsastore.com/articles/learn-spotlight-on-discovery-benefits.html","type":"contains"},{"url":"https://fsastore.com/patiently/weight-loss-get-started.html","type":"contains"},{"url":"https://fsastore.com/fsa-weight-loss.html","type":"contains"}]},"device_target":{"type":"any"},"frequency":"once_per_visit","uses_personalization":true,"data":"","variables_target":null,"page_vars":[]},{"_id":"68f276a9ef8c9dec387e6784","date_filter":{"enabled":false,"from_date":1616108400,"to_date":1616281199},"trigger":{"include_pages":[{"url":"utm_campaign=fsa_email_trigger_welcome-series-email-1-coupon-click-15-wex","type":"contains"},{"url":"utm_campaign=fsa_sms_trigger_welcome-series-sms-1-coupon-click-15-wex","type":"contains"}],"exclude_pages":null},"device_target":{"type":"any"},"frequency":"always","uses_personalization":true,"data":"","variables_target":null,"page_vars":[]},{"_id":"690b1751bfeb703a37332e53","date_filter":{"enabled":false,"from_date":null,"to_date":null},"trigger":{"include_pages":[{"url":"https://hsastore.com/sms-sign-up.html","type":"contains"}],"exclude_pages":[{"url":"insiders","type":"contains"},{"url":"https://hsastore.com/cart","type":"contains"},{"url":"https://hsastore.com/checkout","type":"contains"},{"url":"cart","type":"contains"},{"url":"checkout","type":"contains"},{"url":"mychoiceaccounts","type":"contains"},{"url":"https://hsastore.com/learning","type":"contains"},{"url":"https://hsastore.com/savings-center","type":"contains"},{"url":"https://hsastore.com/resource-center","type":"contains"},{"url":"/eligibility-quiz.html","type":"contains"},{"url":"utm_source=bloomreach\u0026utm_campaign=hsa_email_trigger_welcome-series-email-1-coupon-click\u0026utm_medium=email","type":"contains"},{"url":"utm_source=bloomreach\u0026utm_medium=email\u0026utm_campaign=hsa_email_trigger_welcome-series-email-1-coupon-click","type":"contains"},{"url":"utm_source=bloomreach\u0026utm_campaign=hsa_sms_trigger_welcome-series-sms-1-coupon-click\u0026utm_medium=sms","type":"contains"},{"url":"utm_source=bloomreach\u0026utm_medium=sms\u0026utm_campaign=hsa_sms_trigger_welcome-series-sms-1-coupon-click","type":"contains"},{"url":"/hsa-partnerships.html","type":"contains"},{"type":"regex","regex":"(.*)hsastore\\.com(.*)utm_source=WEX(.*)"},{"type":"regex","regex":"(.*)hsastore\\.com(.*)utm_source=Wex(.*)"},{"type":"regex","regex":"(.*)hsastore\\.com(.*)utm_source=wex(.*)"},{"type":"regex","regex":"(.*)hsastore\\.com(.*)utm_source=Discovery(.*)"},{"type":"regex","regex":"(.*)hsastore\\.com(.*)utm_source=discovery(.*)"},{"type":"regex","regex":"(.*)hsastore\\.com(.*)utm_source=Snyder(.*)"},{"type":"regex","regex":"(.*)hsastore\\.com(.*)utm_source=snyder(.*)"}]},"device_target":{"type":"any"},"frequency":"once_per_visit","uses_personalization":true,"data":"","variables_target":null,"page_vars":[]},{"_id":"690b1770d5f60bddb2178f3c","date_filter":{"enabled":false,"from_date":null,"to_date":null},"trigger":{"include_pages":[{"url":"https://fsastore.com/sms-sign-up.html","type":"contains"}],"exclude_pages":[{"url":"insiders","type":"contains"},{"url":"https://fsastore.com/cart","type":"contains"},{"url":"https://fsastore.com/checkout","type":"contains"},{"url":"https://fsastore.com/hra-store.html","type":"contains"},{"url":"https://fsastore.com/hra-store-spender.html","type":"contains"},{"url":"https://fsastore.com/hra.html","type":"contains"},{"url":"cart","type":"contains"},{"url":"checkout","type":"contains"},{"url":"mychoiceaccounts","type":"contains"},{"url":".com/weight-loss.html","type":"contains"},{"url":"https://fsastore.com/learning","type":"contains"},{"url":"https://fsastore.com/fsa-calculator","type":"contains"},{"url":"https://fsastore.com/savings-center","type":"contains"},{"url":"https://fsastore.com/resource-center","type":"contains"},{"url":"https://fsastore.com/articles","type":"contains"},{"url":"utm_source=bloomreach\u0026utm_campaign=fsa_email_trigger_welcome-series-email-1-coupon-click\u0026utm_medium=email","type":"contains"},{"url":"utm_source=bloomreach\u0026utm_medium=email\u0026utm_campaign=fsa_email_trigger_welcome-series-email-1-coupon-click","type":"contains"},{"url":"utm_source=bloomreach\u0026utm_campaign=fsa_sms_trigger_welcome-series-sms-1-coupon-click\u0026utm_medium=sms","type":"contains"},{"url":"utm_source=bloomreach\u0026utm_medium=sms\u0026utm_campaign=fsa_sms_trigger_welcome-series-sms-1-coupon-click","type":"contains"},{"url":"https://fsastore.com/medicine-and-treatments/vitamins-and-supplements","type":"contains"},{"url":"https://fsastore.com/medicine-and-treatments/pain-relief","type":"contains"},{"url":"https://fsastore.com/medicine-and-treatments/cold-and-allergy","type":"contains"},{"url":"https://fsastore.com/medicine-and-treatments/drug-free-pain-relief","type":"contains"},{"url":"https://fsastore.com/medicine-and-treatments/virus-preparedness","type":"contains"},{"type":"regex","regex":"(.*)fsastore\\.com(.*)utm_source=WEX(.*)"},{"type":"regex","regex":"(.*)fsastore\\.com(.*)utm_source=Wex(.*)"},{"type":"regex","regex":"(.*)fsastore\\.com(.*)utm_source=wex(.*)"},{"type":"regex","regex":"(.*)fsastore\\.com(.*)utm_source=Discovery(.*)"},{"type":"regex","regex":"(.*)fsastore\\.com(.*)utm_source=discovery(.*)"},{"type":"regex","regex":"(.*)fsastore\\.com(.*)utm_source=Snyder(.*)"},{"type":"regex","regex":"(.*)fsastore\\.com(.*)utm_source=snyder(.*)"}]},"device_target":{"type":"any"},"frequency":"once_per_visit","uses_personalization":true,"data":"","variables_target":null,"page_vars":[]},{"_id":"6936fd5e853c90f4107f90a9","date_filter":{"enabled":false,"from_date":null,"to_date":null},"trigger":{"include_pages":[{"type":"regex","regex":"(.*)hsastore\\.com(.*)utm_source=(.*)Equity(.*)"},{"type":"regex","regex":"(.*)hsastore\\.com(.*)utm_source=(.*)equity(.*)"}],"exclude_pages":[{"url":"insiders","type":"contains"},{"url":"https://hsastore.com/cart","type":"contains"},{"url":"https://hsastore.com/checkout","type":"contains"},{"url":"cart","type":"contains"},{"url":"checkout","type":"contains"},{"url":"mychoiceaccounts","type":"contains"},{"url":"https://hsastore.com/learning","type":"contains"},{"url":"https://hsastore.com/savings-center","type":"contains"},{"url":"https://hsastore.com/resource-center","type":"contains"},{"url":"/eligibility-quiz.html","type":"contains"},{"url":"utm_source=bloomreach\u0026utm_campaign=hsa_email_trigger_welcome-series-email-1-coupon-click\u0026utm_medium=email","type":"contains"},{"url":"utm_source=bloomreach\u0026utm_medium=email\u0026utm_campaign=hsa_email_trigger_welcome-series-email-1-coupon-click","type":"contains"},{"url":"utm_source=bloomreach\u0026utm_campaign=hsa_sms_trigger_welcome-series-sms-1-coupon-click\u0026utm_medium=sms","type":"contains"},{"url":"utm_source=bloomreach\u0026utm_medium=sms\u0026utm_campaign=hsa_sms_trigger_welcome-series-sms-1-coupon-click","type":"contains"},{"url":"/hsa-partnerships.html","type":"contains"},{"type":"regex","regex":"(.)hsastore\\.com(.)utm_source=(.)Bank(.)"},{"type":"regex","regex":"(.)hsastore\\.com(.)utm_source=(.)bank(.)"}]},"device_target":{"type":"any"},"frequency":"once_per_visit","uses_personalization":true,"data":"","variables_target":null,"page_vars":[]},{"_id":"6970fce4c641a43da165d7bd","date_filter":{"enabled":false,"from_date":null,"to_date":null},"trigger":{"include_pages":[{"url":"https://fsastore.com/","type":"contains"},{"url":"https://fsastore.com?","type":"contains"},{"url":"https://fsastore.com/?","type":"contains"}],"exclude_pages":[{"url":"insiders","type":"contains"},{"url":"https://fsastore.com/cart","type":"contains"},{"url":"https://fsastore.com/checkout","type":"contains"},{"url":"https://fsastore.com/hra-store.html","type":"contains"},{"url":"https://fsastore.com/hra-store-spender.html","type":"contains"},{"url":"https://fsastore.com/hra.html","type":"contains"},{"url":"cart","type":"contains"},{"url":"checkout","type":"contains"},{"url":"mychoiceaccounts","type":"contains"},{"url":".com/weight-loss.html","type":"contains"},{"url":"utm_source=bloomreach\u0026utm_campaign=fsa_email_trigger_welcome-series-email-1-coupon-click\u0026utm_medium=email","type":"contains"},{"url":"utm_source=bloomreach\u0026utm_medium=email\u0026utm_campaign=fsa_email_trigger_welcome-series-email-1-coupon-click","type":"contains"},{"url":"utm_source=bloomreach\u0026utm_campaign=fsa_sms_trigger_welcome-series-sms-1-coupon-click\u0026utm_medium=sms","type":"contains"},{"url":"utm_source=bloomreach\u0026utm_medium=sms\u0026utm_campaign=fsa_sms_trigger_welcome-series-sms-1-coupon-click","type":"contains"},{"type":"regex","regex":"(.*)fsastore\\.com(.*)utm_source=WEX(.*)"},{"type":"regex","regex":"(.*)fsastore\\.com(.*)utm_source=Wex(.*)"},{"type":"regex","regex":"(.*)fsastore\\.com(.*)utm_source=wex(.*)"},{"type":"regex","regex":"(.*)fsastore\\.com(.*)utm_source=Discovery(.*)"},{"type":"regex","regex":"(.*)fsastore\\.com(.*)utm_source=discovery(.*)"},{"type":"regex","regex":"(.*)fsastore\\.com(.*)utm_source=Snyder(.*)"},{"type":"regex","regex":"(.*)fsastore\\.com(.*)utm_source=snyder(.*)"},{"url":"https://fsastore.com/telehealth.html","type":"contains"},{"url":"https://fsastore.com/telehealth-v2.html","type":"contains"},{"url":"https://fsastore.com/sms-sign-up.html","type":"contains"},{"url":"https://fsastore.com/fsa-weight-loss.html","type":"contains"},{"url":"https://fsastore.com/patiently/weight-loss-get-started.html","type":"contains"}]},"device_target":{"type":"any"},"frequency":"once_per_visit","uses_personalization":true,"data":"","variables_target":null,"page_vars":[]}],"experiments":[],"constantManagedTags":[{"uses_overlay":false,"type":"js","parametrized_definition":"(function(){\n    var segment_cookie = getCookieByName('ajs_anonymous_id'); \n\n    if (segment_cookie) {\n        exponea.identify({ \n            'segment_cookie': segment_cookie \n        });\n    }\n\n    function getCookieByName(cname) {\n        var name = cname + \"=\";\n        var decodedCookie = decodeURIComponent(document.cookie || \"\");\n        var ca = decodedCookie.split(';');\n        for(var i = 0; i \u003c ca.length; i++) {\n            var c = ca[i].trim();\n            if (c.indexOf(name) === 0) {\n                return c.substring(name.length, c.length);\n            }\n        }\n        return \"\";\n    }\n})();\n","trigger":{"include_pages":[{"type":"any"}],"exclude_pages":null},"_id":"682b0b149c204ea2e7b1521e"},{"uses_overlay":false,"type":"js","parametrized_definition":"(function () {\n  'use strict';\n\n  /**\n   * AA2C (Auto Add 2 Cart) – Global JS Tag\n   * ─────────────────────────────────────────────────────────────────────────\n   *\n   * PURPOSE\n   * Allows email deep-links to automatically add a product to the cart when\n   * a customer lands on any page, using the existing SFCC Cart-AddProduct\n   * POST endpoint. Designed to be dropped into a tag manager (e.g. GTM) as\n   * a Custom HTML tag firing on All Pages.\n   *\n   * EMAIL LINK FORMAT\n   *   https://example.com/any-page?aa2c_pid=3816\u0026aa2c_qty=2\n   *\n   * PARAMS\n   *   aa2c_pid  (required) → sellable variant SKU / product ID\n   *   aa2c_qty  (optional) → quantity to add; defaults to 1; capped at MAX_QTY\n   *\n   * HAPPY-PATH FLOW\n   *   1. Tag fires on page load.\n   *   2. Fast-exit guard checks for aa2c_pid in the query string; bails if absent.\n   *   3. Heuristic guards confirm a real human browser session (not a bot/scanner).\n   *   4. If the page isn't yet visible/focused, listeners wait until it is.\n   *   5. A POST is made to Cart-AddProduct with the same payload shape as the\n   *      native PDP JS, so SFCC handles it identically.\n   *   6. On success the aa2c params are stripped from the URL (history.replaceState)\n   *      to prevent re-trigger on future visits, and the user is redirected to /cart.\n   *   7. An idempotency key is written to sessionStorage so that if the user\n   *      navigates back mid-session, the add is skipped and they are sent straight\n   *      to /cart again.\n   *\n   * FAILURE MODES\n   *   - Network error / non-JSON response  → fail silently, stay on current page.\n   *   - SFCC returns data.error === true    → fail silently, stay on current page.\n   *   - sessionStorage unavailable          → idempotency skipped; tag still runs.\n   *   - Bot/prerender detected              → tag waits or exits; no POST made.\n   *\n   * SECURITY / LIMITATIONS\n   *   - Client-side heuristics cannot fully stop sophisticated link scanners.\n   *     Risk is typically compute/analytics noise rather than cart corruption,\n   *     because the cart is session-scoped and SKU/qty are not sensitive data.\n   *   - This tag relies on Cart-AddProduct accepting XHR without a CSRF token.\n   *     Default SFCC config permits this; tighter security policies may not.\n   *     Verify with your SFCC architect before deploying to a hardened environment.\n   *   - For stronger bot guarantees: signed short-links + server-side nonce, or\n   *     WAF rate-limiting on the aa2c_pid parameter.\n   *\n   * BROWSER SUPPORT\n   *   Uses fetch(), URLSearchParams, sessionStorage, and history.replaceState —\n   *   all available in every browser SFCC supports as of 2024. No polyfills needed.\n   */\n\n  /* ─────────────────────────────────────────────────────────────────────────\n   * FAST EXIT\n   * Checked before any allocations so the tag is near-zero cost on pages\n   * that were not reached via an aa2c email link.\n   * ───────────────────────────────────────────────────────────────────────── */\n  if (!location.search || location.search.indexOf('aa2c_pid=') === -1) {\n    return;\n  }\n\n  /* ─────────────────────────────────────────────────────────────────────────\n   * CONFIG\n   * Centralised so ops/devs can update without reading the full tag body.\n   * ───────────────────────────────────────────────────────────────────────── */\n\n  // Full server-relative path to the SFCC add-to-cart endpoint.\n  // The Sites-FSASTORE-Site segment and locale (default) must match your\n  // storefront configuration exactly; a mismatch returns a 404.\n  if (window.location.hostname == 'fsastore.com') {\n    var ADD_TO_CART_PATH = '/on/demandware.store/Sites-FSASTORE-Site/default/Cart-AddProduct';\n  } else if (window.location.hostname == 'hsastore.com') {\n    var ADD_TO_CART_PATH = '/on/demandware.store/Sites-HSASTORE-Site/default/Cart-AddProduct';\n  } else {\n    return;\n  }\n\n  // Where to send the user after a confirmed successful add.\n  var SUCCESS_REDIRECT = '/cart';\n\n  // Upper bound on quantity accepted from the URL parameter.\n  // 25 mirrors the maximum quantity selectable on the native PDP UI;\n  // it does NOT reflect inventory availability (SFCC enforces that server-side).\n  var MAX_QTY = 25;\n\n  // sessionStorage key prefix used for idempotency. The full key is\n  // PREFIX + pid + ':' + qty so that a second link for the same SKU but a\n  // different quantity is treated as a distinct, actionable request.\n  var SESSION_PREFIX = 'aa2c_done:';\n\n  // Value passed as clickSource in the cart payload. Used downstream for\n  // analytics attribution. If this tag is ever repurposed for SMS or push\n  // campaigns, introduce a separate aa2c_src URL parameter and map it here\n  // rather than hardcoding — otherwise those channels will be mis-attributed\n  // as email in your reporting.\n  var CLICK_SOURCE = 'email';\n\n  // Set to true locally when debugging. Emits console.debug statements at\n  // key decision points. MUST be false in production — do not commit as true.\n  var DEBUG = false;\n\n  /* ─────────────────────────────────────────────────────────────────────────\n   * HELPERS\n   * ───────────────────────────────────────────────────────────────────────── */\n\n  // Thin wrapper so debug lines don't litter the tag body. Compiled away\n  // (branch never taken) when DEBUG is false, so production overhead is nil.\n  function log() {\n    if (DEBUG \u0026\u0026 typeof console !== 'undefined' \u0026\u0026 console.debug) {\n      console.debug.apply(console, ['[aa2c]'].concat(Array.prototype.slice.call(arguments)));\n    }\n  }\n\n  /* ─────────────────────────────────────────────────────────────────────────\n   * PARAM PARSING\n   * ───────────────────────────────────────────────────────────────────────── */\n\n  var qs = new URLSearchParams(location.search);\n\n  var pid = (qs.get('aa2c_pid') || '').trim();\n  if (!pid) {\n    // aa2c_pid was present as a bare key (e.g. \"?aa2c_pid=\") but had no value.\n    log('pid empty after trim — exiting');\n    return;\n  }\n\n  // Parse quantity, falling back to 1 for missing/non-numeric values.\n  // Math.min/max enforces the 1–MAX_QTY range so a malformed or spoofed\n  // URL parameter cannot request an unreasonable quantity.\n  var qtyRaw = parseInt(qs.get('aa2c_qty'), 10);\n  var qty = isNaN(qtyRaw) ? 1 : Math.max(1, Math.min(qtyRaw, MAX_QTY));\n\n  log('parsed params — pid:', pid, '| qty:', qty);\n\n  /* ─────────────────────────────────────────────────────────────────────────\n   * IDEMPOTENCY\n   *\n   * Prevents a duplicate add-to-cart POST if the user navigates back to the\n   * landing page within the same browser session (e.g. browser back-button\n   * after visiting /cart).\n   *\n   * Key includes both pid and qty so a follow-up link for the same SKU at a\n   * different quantity is honoured as a new intent rather than silently skipped.\n   *\n   * sessionStorage is tab-scoped and not persisted across sessions, so a\n   * customer opening the same email link in a new tab or a new browser session\n   * will always get a fresh add — which is the expected behaviour.\n   *\n   * If sessionStorage is unavailable (private-browsing restrictions on some\n   * iOS configurations, storage-quota errors) we continue without idempotency\n   * rather than blocking the add entirely. The worst outcome is a duplicate\n   * add in an edge-case scenario; the user can remove the extra item from cart.\n   * ───────────────────────────────────────────────────────────────────────── */\n  var idemKey = SESSION_PREFIX + pid + ':' + qty;\n\n  try {\n    if (sessionStorage.getItem(idemKey) === '1') {\n      log('idempotency key found — redirecting directly to cart');\n      location.replace(SUCCESS_REDIRECT);\n      return;\n    }\n  } catch (e) {\n    log('sessionStorage unavailable — continuing without idempotency:', e);\n  }\n\n  /* ─────────────────────────────────────────────────────────────────────────\n   * HEURISTIC GUARDS\n   *\n   * These checks reduce (but cannot eliminate) execution triggered by email\n   * security scanners, prefetch crawlers, and automated link-checkers that\n   * follow href URLs without rendering a real user session.\n   *\n   * Each guard is individually weak; their value is as a layered stack.\n   * See SECURITY / LIMITATIONS in the header comment for stronger options.\n   * ───────────────────────────────────────────────────────────────────────── */\n\n  /**\n   * Returns true only when the environment looks like an active human browser.\n   *\n   * Checks in order of cost (cheapest first):\n   *   1. navigator.webdriver   — set by Selenium/Playwright/CDP-controlled browsers\n   *   2. visibilityState       — 'hidden' when a scanner loads a page without rendering\n   *   3. hasFocus()            — false in headless or backgrounded tab contexts\n   *   4. frame context         — scanners sometimes load in a sandboxed iframe\n   *   5. navigation type       — 'prerender' indicates Chrome's speculative load,\n   *                              not a real user navigation\n   *\n   * NOTE: visibilityState and hasFocus CAN be false for a real user immediately\n   * after clicking a link in some mail clients (particularly desktop clients that\n   * open a background tab). runWhenReady() handles that case by deferring until\n   * the tab becomes active rather than giving up entirely.\n   */\n  function shouldRun() {\n    if (navigator.webdriver) {\n      log('guard blocked: navigator.webdriver is set');\n      return false;\n    }\n    if (document.visibilityState \u0026\u0026 document.visibilityState !== 'visible') {\n      log('guard blocked: visibilityState =', document.visibilityState);\n      return false;\n    }\n    if (typeof document.hasFocus === 'function' \u0026\u0026 !document.hasFocus()) {\n      log('guard blocked: document does not have focus');\n      return false;\n    }\n    if (window.top !== window.self) {\n      log('guard blocked: running inside an iframe');\n      return false;\n    }\n    try {\n      var nav = performance.getEntriesByType('navigation')[0];\n      if (nav \u0026\u0026 nav.type === 'prerender') {\n        log('guard blocked: navigation type is prerender');\n        return false;\n      }\n    } catch (e) {\n      // performance API unavailable — not a reason to block\n    }\n    return true;\n  }\n\n  /**\n   * Calls fn() immediately if shouldRun() passes, otherwise defers until\n   * one of three signals indicates the tab has become active:\n   *   - visibilitychange  (tab brought to foreground)\n   *   - focus             (window receives focus)\n   *   - pageshow          (page restored from bfcache / fully loaded)\n   *\n   * A `fired` flag ensures fn() is called at most once even if multiple\n   * events fire in quick succession before the async fetch completes.\n   *\n   * Listeners are registered with `capture: true` so they fire before any\n   * page-level handlers that might suppress propagation.\n   */\n  function runWhenReady(fn) {\n    if (shouldRun()) {\n      log('running immediately');\n      fn();\n      return;\n    }\n\n    log('deferring — waiting for tab to become active');\n\n    var fired = false;\n\n    var handler = function () {\n      if (fired || !shouldRun()) return;\n      fired = true;\n\n      // Remove all three listeners as soon as one triggers to avoid leaking\n      // handlers on pages where the user never returns focus.\n      document.removeEventListener('visibilitychange', handler, true);\n      window.removeEventListener('focus', handler, true);\n      window.removeEventListener('pageshow', handler, true);\n\n      log('deferred execution triggered');\n      fn();\n    };\n\n    document.addEventListener('visibilitychange', handler, true);\n    window.addEventListener('focus', handler, true);\n    window.addEventListener('pageshow', handler, true);\n  }\n\n  /* ─────────────────────────────────────────────────────────────────────────\n   * URL CLEANUP\n   *\n   * Strip the aa2c_* parameters from the visible URL before we POST.\n   * This prevents the parameters from appearing in:\n   *   - The user's browser history (they'd see the raw params if they open history)\n   *   - Shared / bookmarked URLs (a shared link would re-trigger aa2c for the\n   *     recipient, which is confusing and may inflate add-to-cart analytics)\n   *   - Referrer headers sent to third-party scripts on /cart\n   *\n   * history.replaceState modifies the address bar without triggering a navigation,\n   * so it is effectively free and does not reload the page or break the fetch\n   * that follows. We call it before the POST so the cleaned URL is already in\n   * place if the user manages to screenshot / copy the address bar during load.\n   *\n   * If history.replaceState is unavailable (should not happen in any supported\n   * browser) we skip silently — cosmetic concern only, not a functional blocker.\n   * ───────────────────────────────────────────────────────────────────────── */\n  function cleanUrl() {\n    try {\n      var clean = new URL(location.href);\n      clean.searchParams.delete('aa2c_pid');\n      clean.searchParams.delete('aa2c_qty');\n      history.replaceState(null, '', clean.toString());\n      log('url cleaned —', clean.toString());\n    } catch (e) {\n      log('url cleanup skipped:', e);\n    }\n  }\n\n  /* ─────────────────────────────────────────────────────────────────────────\n   * CORE EXECUTION\n   *\n   * Called once shouldRun() has passed (either immediately or after deferral).\n   *\n   * POST PAYLOAD SHAPE\n   *   Mirrors what the native SFCC PDP JavaScript sends so Cart-AddProduct\n   *   processes it through the same code path. Fields:\n   *     pid              → variant SKU\n   *     childProducts    → JSON array; empty for simple products\n   *     quantity         → string-cast integer (SFCC expects a string here)\n   *     clickSource      → analytics attribution; see CLICK_SOURCE config above\n   *     isQuickViewModal → always false for deep-link adds\n   *     options          → JSON array of product options; empty for standard SKUs\n   *\n   * RESPONSE HANDLING\n   *   SFCC returns JSON with an `error` boolean.\n   *   - error === true  → product could not be added (e.g. out of stock, invalid\n   *                        SKU, cart limit reached). Stay on page so the customer\n   *                        sees the PDP rather than an empty or confusing /cart.\n   *   - error !== true  → treat as success and redirect.\n   *\n   *   The .catch on resp.json() handles cases where the server returns a non-JSON\n   *   body (e.g. a 302 redirect response, a WAF block page). An empty object {}\n   *   is returned, and because {}.error !== true the tag would redirect. This is\n   *   intentional: a redirect or WAF response to a cart POST likely means the\n   *   item was processed or the session was redirected by the platform. If your\n   *   environment can return non-JSON for genuine failure cases, add a resp.ok\n   *   check before resp.json() and treat !resp.ok as an error.\n   *\n   * IDEMPOTENCY KEY WRITE ORDER\n   *   The key is written to sessionStorage BEFORE location.replace() is called.\n   *   This ordering is deliberate: location.replace() triggers an immediate\n   *   navigation which may unload the current JS context before a subsequent\n   *   async write could complete. Writing first guarantees the key is persisted\n   *   so the user cannot re-trigger a duplicate add if they navigate back.\n   * ───────────────────────────────────────────────────────────────────────── */\n  function execute() {\n    cleanUrl();\n\n    var body = new URLSearchParams({\n      pid: pid,\n      childProducts: '[]',\n      quantity: String(qty),\n      clickSource: CLICK_SOURCE,\n      isQuickViewModal: 'false',\n      options: '[]'\n    });\n\n    log('posting to', ADD_TO_CART_PATH, '— pid:', pid, 'qty:', qty);\n\n    fetch(ADD_TO_CART_PATH, {\n      method: 'POST',\n      headers: {\n        // SFCC Cart-AddProduct expects form-encoded data, not JSON.\n        'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',\n        // Tells SFCC this is an XHR request; required for it to return JSON\n        // rather than a full HTML page response.\n        'X-Requested-With': 'XMLHttpRequest'\n      },\n      // same-origin ensures the session cookie is included, which is how SFCC\n      // associates the add with the correct customer basket.\n      credentials: 'same-origin',\n      body: body\n    })\n      .then(function (resp) {\n        // Attempt to parse the response as JSON. If parsing fails (non-JSON body\n        // — see RESPONSE HANDLING note above) fall back to an empty object so\n        // the .then chain can continue with consistent types.\n        return resp.json().catch(function () {\n          log('response was not valid JSON — treating as success');\n          return {};\n        });\n      })\n      .then(function (data) {\n        if (data \u0026\u0026 data.error === true) {\n          // SFCC explicitly reported a cart error (out of stock, invalid SKU, etc.)\n          // Stay on the current page so the customer sees the PDP context rather\n          // than arriving at /cart with nothing in it.\n          log('cart error returned by SFCC — staying on page:', data);\n          return;\n        }\n\n        // Write idempotency key BEFORE redirecting — see IDEMPOTENCY KEY WRITE\n        // ORDER in the block comment above for why ordering matters here.\n        try {\n          sessionStorage.setItem(idemKey, '1');\n        } catch (e) {\n          log('could not write idempotency key:', e);\n        }\n\n        log('add succeeded — redirecting to', SUCCESS_REDIRECT);\n        location.replace(SUCCESS_REDIRECT);\n      })\n      .catch(function (err) {\n        // Network-level failure (offline, DNS error, CORS issue, etc.).\n        // Fail silently and leave the customer on the current page; they can\n        // add to cart manually via the standard PDP flow.\n        log('fetch failed — staying on page:', err);\n      });\n  }\n\n  /* ─────────────────────────────────────────────────────────────────────────\n   * ENTRY POINT\n   * ───────────────────────────────────────────────────────────────────────── */\n  runWhenReady(execute);\n\n})();","trigger":{"include_pages":[{"type":"regex","regex":"aa2c_pid=[0-9]+"}],"exclude_pages":null},"_id":"69ab027cd3612905a9222f64"}],"vars":{"data":[]}}