1(function(){"use strict";window.dataLayer=window.dataLayer||[];var VERSION="1.0.0",DEBUG=/[?&]comu_tracking_debug=1/.test(window.location.search),dataEl=document.getElementById("comu-tracking-data");if(!dataEl)return;var bootstrapData;try{bootstrapData=JSON.parse(dataEl.textContent)}catch(e){return}var currency=bootstrapData.currency||"USD",pageType=bootstrapData.page_type||"",template=bootstrapData.template||"",cartSnapshot={};bootstrapData.cart&&bootstrapData.cart.items&&bootstrapData.cart.items.forEach(function(item){cartSnapshot[String(item.variant_id)]={quantity:item.quantity,product_id:item.product_id,title:item.title,variant_title:item.variant_title,sku:item.sku,price:item.price,handle:item.handle}});var currentProduct=bootstrapData.product||null,currentVariantId=currentProduct?currentProduct.variant.id:null;function uid(){return Date.now().toString(36)+Math.random().toString(36).slice(2,8)}function log(){if(DEBUG){var args=["[ComuTracking]"].concat(Array.prototype.slice.call(arguments));console.log.apply(console,args)}}function meta(extra){var obj={schema_version:"1.0",source:"comu_theme",event_id:uid(),page_type:pageType,template:template};if(extra)for(var k in extra)extra.hasOwnProperty(k)&&(obj[k]=extra[k]);return obj}function push(eventName,params){try{var payload={event:eventName,tracking:meta()};if(params)for(var k in params)params.hasOwnProperty(k)&&(payload[k]=params[k]);window.dataLayer.push(payload),log("push",eventName,payload)}catch(e){log("error push",e)}}function pushEcommerce(eventName,ecommerce,extraMeta){try{window.dataLayer.push({ecommerce:null});var payload={event:eventName,tracking:meta(extraMeta),ecommerce:ecommerce};window.dataLayer.push(payload),log("pushEcommerce",eventName,payload)}catch(e){log("error pushEcommerce",e)}}function buildItemFromVariant(variantData,productData){var sku=variantData.sku||String(variantData.id),variantTitle=variantData.title;return variantTitle==="Default Title"&&(variantTitle=""),{item_id:sku,item_name:productData.title,item_brand:productData.vendor||"COMU",item_category:productData.type||"",item_variant:variantTitle,price:variantData.price,quantity:1,shopify_product_id:String(productData.id),shopify_variant_id:String(variantData.id),product_handle:productData.handle}}function normalizeAjaxItem(ajaxItem){var variantTitle=ajaxItem.variant_title||"";return variantTitle==="Default Title"&&(variantTitle=""),{item_id:ajaxItem.sku||String(ajaxItem.variant_id||ajaxItem.id),item_name:ajaxItem.product_title||ajaxItem.title||"",item_brand:ajaxItem.vendor||"COMU",item_category:ajaxItem.product_type||"",item_variant:variantTitle,price:(ajaxItem.final_price||ajaxItem.price||0)/100,quantity:ajaxItem.quantity||1,shopify_product_id:String(ajaxItem.product_id||""),shopify_variant_id:String(ajaxItem.variant_id||ajaxItem.id||""),product_handle:ajaxItem.handle||""}}if(pageType==="product"&¤tProduct){var viewItem=buildItemFromVariant(currentProduct.variant,currentProduct);pushEcommerce("view_item",{currency:currency,value:currentProduct.variant.price,items:[viewItem]})}document.addEventListener("variant:add",function(event){try{var detail=event.detail||{},items=detail.items||(detail.item?[detail.item]:[]);if(!items.length)return;var gaItems=items.map(function(item){return normalizeAjaxItem(item)}),totalValue=gaItems.reduce(function(sum,i){return sum+i.price*i.quantity},0);pushEcommerce("add_to_cart",{currency:currency,value:totalValue,items:gaItems}),detail.cart&&detail.cart.items&&(cartSnapshot={},detail.cart.items.forEach(function(ci){cartSnapshot[String(ci.variant_id||ci.id)]={quantity:ci.quantity,product_id:ci.product_id,title:ci.product_title||ci.title,variant_title:ci.variant_title,sku:ci.sku,price:(ci.final_price||ci.price||0)/100,handle:ci.handle}}))}catch(e){log("error add_to_cart",e)}}),document.addEventListener("variant:change",function(event){try{var detail=event.detail||{},variant=detail.variant,previousVariant=detail.previousVariant;if(!variant||!previousVariant||variant.id===previousVariant.id)return;var variantTitle=variant.title||"";if(variantTitle==="Default Title"&&(variantTitle=""),push("comu_variant_select",{item_id:variant.sku||String(variant.id),shopify_product_id:currentProduct?String(currentProduct.id):"",shopify_variant_id:String(variant.id),previous_shopify_variant_id:String(previousVariant.id),variant_name:variantTitle}),currentProduct){var found=currentProduct.variants.find(function(v){return v.id===variant.id});found&&(currentProduct.variant=found,currentVariantId=found.id)}}catch(e){log("error variant_select",e)}}),document.documentElement.addEventListener("cart:change",function(event){try{var detail=event.detail||{};if(detail.baseEvent==="variant:add"){if(detail.cart&&detail.cart.items){var newSnapsh
1ot={};detail.cart.items.forEach(function(ci){newSnapshot[String(ci.variant_id||ci.id)]={quantity:ci.quantity,product_id:ci.product_id,title:ci.product_title||ci.title,variant_title:ci.variant_title,sku:ci.sku,price:(ci.final_price||ci.price||0)/100,handle:ci.handle}}),cartSnapshot=newSnapshot}return}if(!detail.cart||!detail.cart.items)return;var newSnapshot={};detail.cart.items.forEach(function(ci){newSnapshot[String(ci.variant_id||ci.id)]={quantity:ci.quantity,product_id:ci.product_id,title:ci.product_title||ci.title,variant_title:ci.variant_title,sku:ci.sku,price:(ci.final_price||ci.price||0)/100,handle:ci.handle}});var removedItems=[];for(var vid in cartSnapshot)if(cartSnapshot.hasOwnProperty(vid)){var oldQty=cartSnapshot[vid].quantity,newQty=newSnapshot[vid]&&newSnapshot[vid].quantity||0;if(newQty<oldQty){var si=cartSnapshot[vid],variantTitle=si.variant_title||"";variantTitle==="Default Title"&&(variantTitle=""),removedItems.push({item_id:si.sku||vid,item_name:si.title||"",item_brand:"COMU",item_variant:variantTitle,price:si.price,quantity:oldQty-newQty,shopify_product_id:String(si.product_id||""),shopify_variant_id:vid,product_handle:si.handle||""})}}if(removedItems.length){var totalValue=removedItems.reduce(function(sum,i){return sum+i.price*i.quantity},0);pushEcommerce("remove_from_cart",{currency:currency,value:totalValue,items:removedItems})}
1cartSnapshot=newSnapshot}catch(e){log("error cart:change",e)}});function sendViewCart(){var items=[];for(var vid in cartSnapshot)if(cartSnapshot.hasOwnProperty(vid)){var si=cartSnapshot[vid],variantTitle=si.variant_title||"";variantTitle==="Default Title"&&(variantTitle=""),items.push({item_id:si.sku||vid,item_name:si.title||"",item_brand:"COMU",item_variant:variantTitle,price:si.price,quantity:si.quantity,shopify_product_id:String(si.product_id||""),shopify_variant_id:vid,product_handle:si.handle||""})}var totalValue=items.reduce(function(sum,i){return sum+i.price*i.quantity},0);pushEcommerce("view_cart",{currency:currency,value:totalValue,items:items})}pageType==="cart"&&sendViewCart();function observeCartDrawer(el){if(el){var observer=new MutationObserver(function(mutations){mutations.forEach(function(m){m.attributeName==="open"&&el.hasAttribute("open")&&sendViewCart()})});observer.observe(el,{attributes:!0,attributeFilter:["open"]})}}observeCartDrawer(document.querySelector("cart-drawer")),observeCartDrawer(document.querySelector("cart-notification-drawer")),document.addEventListener("click",function(event){try{var el=event.target.closest("[data-comu-track-component]");if(!el||el.hasAttribute("data-comu-sticky-add")||el.hasAttribute("data-comu-pc-action"))return;var component=el.getAttribute("data-comu-track-component")||"",placement=el.getAttribute("data-comu-track-placement")||"",label=el.getAttribute("data-comu-track-label")||el.textContent.trim().slice(0,80)||"",targetUrl=el.getAttribute("data-comu-track-url")||el.getAttribute("href")||"",sectionId=el.getAttribute("data-comu-track-section")||"";if(!sectionId){var sectionEl=el.closest("[data-section-id]")||el.closest(".shopify-section");sectionEl&&(sectionId=sectionEl.getAttribute("data-section-id")||sectionEl.id||"")}push("comu_component_click",{component:component,action:"click",placement:placement,label:label,target_url:targetUrl,section_id:sectionId,product_handle:currentProduct?currentProduct.handle:""})}catch(e){log("error component_click",e)}}),document.addEventListener("click",function(event){try{var bar=event.target.closest(".kaching-bundles__bar-main");if(bar){var barEl=bar.closest("[data-deal-bar-id]"),dealId=barEl?barEl.getAttribute("data-deal-bar-id"):"",title=bar.querySelector(".kaching-bundles__bar-title");push("comu_component_click",{component:"kaching_bundle_select",action:"click",placement:"bundle_bar",label:title?title.textContent.trim().slice(0,80):dealId,target_url:"",section_id:"",product_handle:currentProduct?currentProduct.handle:""});return}var swatch=event.target.closest(".kaching-bundles__swatch-buttons__button");if(swatch){var value=swatch.getAttribute("data-value")||"";push("comu_component_click",{component:"kaching_bundle_variant",action:"click",placement:"bundle_swatch",label:value,target_url:"",section_id:"",product_handle:currentProduct?currentProduct.handle:""});return}}catch(e){log("error kaching_click",e)}}),document.addEventListener("toggle",function(event){try{var details=event.target;if(!details||details.tagName!=="DETAILS")return;var faqContainer=details.closest("[data-comu-track-faq]");if(!faqContainer)return;var sectionId=faqContainer.getAttribute("data-comu-track-faq")||"",summary=details.querySelector("summary"),label=summary?summary.textContent.trim().slice(0,80):"";push("comu_component_click",{component:"product_faq_toggle",action:details.open?"expand":"collapse",placement:"faq",label:label,target_url:"",section_id:sectionId,product_handle:currentProduct?currentProduct.handle:""})}catch(e){log("error faq_toggle",e)}},!0);var observedCards=new WeakSet,pendingImpressions={},impressionTimer=null;function flushImpressions(){for(var listId in pendingImpressions)if(pendingImpressions.hasOwnProperty(listId)){var batch=pendingImpressions[listId];if(batch.items.length){var totalValue=batch.items.reduce(function(sum,i){return sum+i.price*i.quantity},0);pushEcommerce("view_item_list",{currency:currency,value:totalValue,item_list_id:listId,item_list_name:batch.listName,items:batch.items})}}pendingImpressions={},impressionTimer=null}function scheduleFlush(){impressionTimer||(impressionTimer=setTimeout(flushImpressions,200))}
1function handleItemIntersection(entries){entries.forEach(function(entry){if(entry.isIntersecting){var card=entry.target;if(!observedCards.has(card)){observedCards.add(card);var itemJsonStr=card.getAttribute("data-item-json");if(itemJsonStr)try{var item=JSON.parse(itemJsonStr),listId=item.item_list_id||"unknown",listName=item.item_list_name||"";pendingImpressions[listId]||(pendingImpressions[listId]={listName:listName,items:[]}),pendingImpressions[listId].items.push(item),scheduleFlush()}catch(e){log("error parsing item json",e)}}}})}var itemObserver=null;typeof IntersectionObserver!="undefined"&&(itemObserver=new IntersectionObserver(handleItemIntersection,{threshold:.5}));function scanItemCards(root){if(itemObserver){var cards=(root||document).querySelectorAll("[data-comu-track-item]");cards.forEach(function(card){observedCards.has(card)||itemObserver.observe(card)})}}document.addEventListener("click",function(event){try{var link=event.target.closest('[data-comu-track-item] a[href*="/products/"]');if(!link||link.closest("[data-comu-pc-action]")||link.hasAttribute("data-comu-pc-action"))return;var card=link.closest("[data-comu-track-item]");if(!card)return;var itemJsonStr=card.getAttribute("data-item-json");if(!itemJsonStr)return;var item=JSON.parse(itemJsonStr);pushEcommerce("select_item",{currency:currency,item_list_id:item.item_list_id||"",item_list_name:item.item_list_name||"",items:[item]})}catch(e){log("error select_item",e)}});var leadEl=document.querySelector("[data-comu-track-lead-success]");leadEl&&push("generate_lead",{lead_type:leadEl.getAttribute("data-comu-track-lead-type")||"contact",placement:leadEl.getAttribute("data-comu-track-lead-placement")||""}),document.querySelectorAll("[data-comu-vt-modal-open][data-comu-track-component]").forEach(function(btn){btn.addEventListener("click",function(){try{push("comu_component_click",{component:btn.getAttribute("data-comu-track-component")||"",action:"click",placement:btn.getAttribute("data-comu-track-placement")||"modal",label:btn.getAttribute("data-comu-track-label")||"",target_url:"",section_id:btn.getAttribute("data-comu-track-section")||"",product_handle:currentProduct?currentProduct.handle:""})}catch(e){log("error video_modal_click",e)}})}),scanItemCards(document),document.addEventListener("shopify:section:load",function(event){var section=event.target;section&&scanItemCards(section)}),window.ComuTracking={version:VERSION,push:push,pushEcommerce:pushEcommerce,normalizeAjaxItem:normalizeAjaxItem,trackAddToCart:function(items){if(!(!items||!items.length)){var gaItems=items.map(function(item){return normalizeAjaxItem(item)}),totalValue=gaItems.reduce(function(sum,i){return sum+i.price*i.quantity},0);pushEcommerce("add_to_cart",{currency:currency,value:totalValue,items:gaItems})}},scan:scanItemCards},log("initialized",VERSION,{pageType:pageType,template:template})})(); 2//# sourceMappingURL=/cdn/shop/t/147/assets/comu-tracking.js.map?v=123820726644777247201790135656
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.