document.documentElement.style.setProperty("--64c285126df9f10f76001a28-w", "" + document.currentScript.parentElement.clientWidth); window["preload_data_64c285126df9f10f76001a28"] = {"height":1,"width":5000,"widgets":[]}; window["behaviors_data_64c285126df9f10f76001a28"] = [{"steps":[{"id":"7sat5-j6uk2y4njuln5ed","stateKey":"newTrigger","parentId":"","steps":[],"isStepValid":true,"isExpanded":true,"stepLabel":"Execute Javascript","stepContent":"Load data from Javascript","data":{"type":"Load Data","formText":"Execute Javascript","connection":"","data":"","loadType":"executeJs","details":{"jsSnippet":"window.ZMAGS_ANALYTICS_API = window.ZMAGS_ANALYTICS_API || {};\nZMAGS_ANALYTICS_API.EXPERIENCE_NAME_CACHE = {};\nZMAGS_ANALYTICS_API.INTERSECTION_OBSERVER = null;\nZMAGS_ANALYTICS_API.PLUS_ICONS = [\"\"]\nZMAGS_ANALYTICS_API.MUTATION_OBSERVER = null;\nZMAGS_ANALYTICS_API.EXPERIENCE_TYPES = [\"HERO\", \"BANNER\", \"MODULE\", \"VIDEO\", \"PDP\"]\nZMAGS_ANALYTICS_API.EVENTS_FIRED = ZMAGS_ANALYTICS_API?.EVENTS_FIRED || {\n \"click_events\": []\n};\n\nZMAGS_ANALYTICS_API.getExperienceName = function (contextWindow, experienceId) {\n if (!ZMAGS_ANALYTICS_API.EXPERIENCE_NAME_CACHE[experienceId]) {\n const expname = contextWindow?.[`${experienceId}_1_STATE`]?.viewer?.experiences?.[experienceId]?.model?.name || \"\";\n ZMAGS_ANALYTICS_API.EXPERIENCE_NAME_CACHE[experienceId] = expname;\n }\n return ZMAGS_ANALYTICS_API.EXPERIENCE_NAME_CACHE[experienceId];\n}\n\nZMAGS_ANALYTICS_API.customEvent = function (name, args) {\n top.window.dataLayer = top.window.dataLayer || [];\n let data = { event: name };\n for (let key in args) {\n if (args.hasOwnProperty(key)) {\n data[key] = args[key];\n }\n }\n top.window.dataLayer.push(data);\n}\n\nZMAGS_ANALYTICS_API.trackLink = function (link, experienceName) {\n const url = link.href;\n const scene = link.closest(\"[class^='scene-']\")?.className || \"\";\n const event = {\n \"zmags_exp\": experienceName,\n \"zmags_exp_type\": ZMAGS_ANALYTICS_API.EXPERIENCE_TYPES.filter(name => experienceName.toLocaleUpperCase().includes(name))[0] || \"experience\",\n \"zmags_int\": \"click_link\",\n \"zmags_scene\": scene,\n \"zmags_url\": url\n }\n if (!document.hidden) {\n ZMAGS_ANALYTICS_API.customEvent(\"zmags\", event);\n ZMAGS_ANALYTICS_API.EVENTS_FIRED['click_events'].push(event)\n }\n};\n\nZMAGS_ANALYTICS_API.trackAddToCart = function (prodID, experienceName) {\n var modal = document.getElementById('quickViewModal');\n if (!modal) return;\n\n var addToCartButton = modal.querySelector('.add-to-cart.btn.btn-primary.new-quick-view-modal');\n if (!addToCartButton) return;\n\t\n\tvar productPrice = modal.querySelector('.value').textContent.trim();\n\t//console.log(productPrice);\n addToCartButton.addEventListener('click', function () {\n\t\t//console.log('atc clicked');\n var event = {\n \"zmags_exp\": experienceName,\n \"zmags_exp_type\": ZMAGS_ANALYTICS_API.EXPERIENCE_TYPES.filter(name => experienceName.toLocaleUpperCase().includes(name))[0] || \"experience\",\n \"zmags_int\": \"click_add_to_cart\",\n\t\t\t\"zmags_url\": prodID,\n\t\t\t\"zmags_value\": productPrice\n\t\t\t\n // You can add more details here if needed\n };\n\n ZMAGS_ANALYTICS_API.customEvent(\"zmags\", event);\n ZMAGS_ANALYTICS_API.EVENTS_FIRED['click_events'].push(event);\n });\n};\n\nZMAGS_ANALYTICS_API.trackQV = function (prodID, experienceName, viewerContainer) {\n const currentScene = viewerContainer.querySelector('[class^=\"scene-\"][style*=\"visibility: inherit\"][style*=\"opacity:\"]:not(.scene-background, .scene-overlay), [class^=\"scene-\"][style*=\"visibility: visible\"]:not(.scene-background, .scene-overlay), [class^=\"scene-\"][style*=\"visibility:visible\"]:not(.scene-background, .scene-overlay)')?.className || \"\";\n const event = {\n \"zmags_exp\": experienceName,\n \"zmags_exp_type\": ZMAGS_ANALYTICS_API.EXPERIENCE_TYPES.filter(name => experienceName.toLocaleUpperCase().includes(name))[0] || \"experience\",\n \"zmags_int\": \"click_quickview\",\n \"zmags_scene\": currentScene,\n \"zmags_url\": prodID \n }\n if (!document.hidden) {\n ZMAGS_ANALYTICS_API.customEvent(\"zmags\", event);\n ZMAGS_ANALYTICS_API.EVENTS_FIRED['click_events'].push(event)\n }\n\t\n\tZMAGS_ANALYTICS_API.trackAddToCart(prodID, experienceName);\n};\n\nZMAGS_ANALYTICS_API.trackSceneChange = function (viewerContainer, experienceId, experienceName) {\n const activeScene = viewerContainer.querySelector('[class^=\"scene-\"][style*=\"visibility: inherit\"][style*=\"opacity:\"]:not(.scene-background, .scene-overlay), [class^=\"scene-\"][style*=\"visibility: visible\"]:not(.scene-background, .scene-overlay), [class^=\"scene-\"][style*=\"visibility:visible\"]:not(.scene-background, .scene-overlay)')?.className || \"\";\n const ordinal = viewerContainer?.dataset?.ordinal || 1\n console.log(`experienceId: `, experienceId, activeScene)\n if (!ZMAGS_ANALYTICS_API.EVENTS_FIRED[`${experienceId}_${ordinal}_scene_${activeScene}`] && !document.hidden) {\n ZMAGS_ANALYTICS_API.customEvent(\"zmags\", {\n \"zmags_exp\": experienceName,\n \"zmags_exp_type\": ZMAGS_ANALYTICS_API.EXPERIENCE_TYPES.filter(name => experienceName.toLocaleUpperCase().includes(name))[0] || \"experience\",\n \"zmags_int\": \"view\",\n \"zmags_scene\": activeScene\n });\n ZMAGS_ANALYTICS_API.EVENTS_FIRED[`${experienceId}_${ordinal}_scene_${activeScene}`] = true\n }\n}\n\nfunction waitForModalAndExecuteAction(container, experienceId, experienceName) {\n var checkModal = setInterval(function() {\n var quickViewModal = document.getElementById('quickViewModal');\n if (quickViewModal && getComputedStyle(quickViewModal).display !== 'none') {\n clearInterval(checkModal); // Stop checking once the modal is found and visible\n\n // Now that the modal is visible, run the following code\n var qvsAnchors = document.querySelectorAll('a[id^=\"zmags-qv\"]');\n if (qvsAnchors.length > 0) {\n var href = qvsAnchors[qvsAnchors.length - 1].getAttribute('href');\n var urlParams = new URLSearchParams(href.split('?')[1]);\n var pid = urlParams.get('pid');\n ZMAGS_ANALYTICS_API.trackQV(pid, `${experienceId} - ${experienceName}`, container);\n }\n }\n }, 200); // Check every 200 milliseconds\n}\n\nZMAGS_ANALYTICS_API.trackExperienceSceneView = function (viewerContainer, experienceId) {\n const observerConfig = {\n attributes: true,\n childList: true,\n };\n const sceneContaniers = Array.from(viewerContainer.querySelectorAll('.scene-background') || []).map(ele => {\n if (!ele.parentNode.dataset.analyticsInitiated) {\n ele.parentNode.dataset.experienceId = experienceId\n ele.parentNode.dataset.analyticsInitiated = true\n return ele.parentNode\n }\n return null\n }).filter(ele => ele !== null)\n sceneContaniers.forEach((container) => {\n const experienceId = container.dataset.experienceId;\n const experienceName = ZMAGS_ANALYTICS_API.EXPERIENCE_NAME_CACHE[`${experienceId}`]\n //ZMAGS_ANALYTICS_API.trackSceneChange(container, experienceId, experienceName)\n container.addEventListener(\"click\", function (event) {\n const anchorTag = event.target?.closest('a') || {}\n if (anchorTag.tagName === \"A\" && !anchorTag.href.includes('openQuickview')) {\n ZMAGS_ANALYTICS_API.trackLink(anchorTag, `${experienceId} - ${experienceName}`)\n }else{\n\t\t\t\twaitForModalAndExecuteAction(container, experienceId, experienceName);\n\t\t\t}\n })\n ZMAGS_ANALYTICS_API.MUTATION_OBSERVER.observe(container, observerConfig)\n })\n}\n\nZMAGS_ANALYTICS_API.setupTracking = function (context, contextWindow) {\n const viewerContainers = context.querySelectorAll('[class^=\"zmags-viewer-container\"][data-zmags-initiated]:not([data-analytics-initiated])');\n\n for (let viewerContainer of viewerContainers) {\n const experienceId = viewerContainer.dataset.experience;\n ZMAGS_ANALYTICS_API.getExperienceName(contextWindow, experienceId);\n ZMAGS_ANALYTICS_API.INTERSECTION_OBSERVER.observe(viewerContainer)\n viewerContainer.dataset.analyticsInitiated = true\n }\n const iframes = Array.from(context.querySelectorAll(\"iframe:not([data-analytics-error])\"))\n iframes.forEach(function (iframe) {\n try {\n const iframeDoc = iframe.contentDocument || iframe.contentWindow.document;\n const iframeWindow = iframe.contentWindow;\n ZMAGS_ANALYTICS_API.setupTracking(iframeDoc, iframeWindow);\n } catch (e) {\n iframe.dataset.analyticsError = true\n console.log(\"Failed to access iframe, probably because it is from a different origin.\");\n }\n });\n}\n\nfunction isElementInViewport(element) {\n const sceneContainer = element.querySelectorAll('[class=\"scene-background\"]')[0] || element\n const rect = sceneContainer.getBoundingClientRect();\n const viewportHeight = window.innerHeight || document.documentElement.clientHeight;\n return ((rect.top >= 0 && rect.top <= viewportHeight) || (rect.bottom >= 0 && rect.bottom <= viewportHeight));\n}\n\nconst mutationObserver = ZMAGS_ANALYTICS_API.MUTATION_OBSERVER || new MutationObserver((mutationsList, observer) => {\n const mutation = mutationsList[0]\n if (!mutation) return;\n const viewerContainer = mutation.target\n const experienceId = viewerContainer.dataset.experienceId;\n const experienceName = ZMAGS_ANALYTICS_API.EXPERIENCE_NAME_CACHE[`${experienceId}`]\n if (isElementInViewport(viewerContainer)) {\n setTimeout(() => {\n //ZMAGS_ANALYTICS_API.trackSceneChange(viewerContainer, experienceId, experienceName)\n }, 500)\n }\n});\n\nif (!ZMAGS_ANALYTICS_API.MUTATION_OBSERVER) ZMAGS_ANALYTICS_API.MUTATION_OBSERVER = mutationObserver;\n\nfunction handleIntersection(entries) {\n entries.forEach(entry => {\n if (entry.isIntersecting) {\n const viewerContainer = entry.target\n const experienceId = viewerContainer.dataset.experience;\n //ZMAGS_ANALYTICS_API.trackSceneChange(viewerContainer, experienceId, ZMAGS_ANALYTICS_API.EXPERIENCE_NAME_CACHE[`${experienceId}`])\n ZMAGS_ANALYTICS_API.trackExperienceSceneView(entry.target, experienceId)\n }\n });\n}\n\nconst options = {\n root: null,\n rootMargin: '0px',\n threshold: 0\n};\n\nconst observer = ZMAGS_ANALYTICS_API.INTERSECTION_OBSERVER || new IntersectionObserver(handleIntersection, options);\n\nif (!ZMAGS_ANALYTICS_API.INTERSECTION_OBSERVER) ZMAGS_ANALYTICS_API.INTERSECTION_OBSERVER = observer\n\n\nsetInterval(function () {\n ZMAGS_ANALYTICS_API.setupTracking(document, window);\n}, 500);\n","variables":[],"jsSnippetMetaData":"const _experienceId = 'BEHAVIOR_EXPERIENCEID_PLACEHOLDER';\nconst _model = window.ZMAGS_API.experiences[_experienceId].model;\n"}}}]}];