FileMaster
Search
Toggle Dark Mode
Home
/
.
/
wp-content
/
plugins
/
surecart
/
packages
/
blocks-next
/
build
/
scripts
/
google
Edit File: index.js
var e={d:function(t,n){for(var i in n)e.o(n,i)&&!e.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:n[i]})},o:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}},t={};e.d(t,{s:function(){return i}});const n=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:scData?.currency;return["BIF","BYR","CLP","DJF","GNF","ISK","JPY","KMF","KRW","PYG","RWF","UGX","VND","VUV","XAF","XAG","XAU","XBA","XBB","XBC","XBD","XDR","XOF","XPD","XPF","XPT","XTS"].includes(t?.toUpperCase())?e:e/100},i=(e,t)=>{(window.dataLayer||window.gtag)&&t&&(window.gtag?window.gtag("event",e,t):(window.dataLayer.push({ecommerce:null}),window.dataLayer.push({event:e,ecommerce:t})))};document.addEventListener("scSearched",(e=>{i("search",{search_term:e.detail?.searchString})})),window.addEventListener("scProductsViewed",(e=>{const t=e.detail,{pageTitle:n,products:c}=t;i("view_item_list",{item_list_name:n,items:t&&c&&c.map((e=>({item_id:e&&e.id,item_name:e&&e.name,...e&&e.product_collections&&e.product_collections.data&&e.product_collections.data.length?{item_category:e.product_collections.data.map((e=>e.name)).join(", ")}:{},item_list_name:t.pageTitle})))})})),window.addEventListener("scAddedToCart",(e=>{const t=e.detail;t?.price?.product&&i("add_to_cart",{currency:t.price?.currency,value:t?.price?.converted_amount||0,items:[{item_id:t.price?.product?.id,item_name:t.price?.product?.name,item_variant:(t.variant_options||[]).join(" / "),price:t?.price?.converted_amount||0,currency:t.price?.currency,quantity:t.quantity,discount:t?.discount_amount?t?.converted_discount_amount:0}]})})),window.addEventListener("scRemovedFromCart",(e=>{const t=e.detail;t?.price?.product&&i("remove_from_cart",{currency:t.price?.currency,value:t?.price?.converted_amount||0,items:[{item_id:t.price?.product?.id,item_name:t.price?.product?.name,item_variant:(t.variant_options||[]).join(" / "),price:t?.price?.converted_amount||0,currency:t.price?.currency,quantity:t.quantity,discount:t?.discount_amount?t?.converted_discount_amount:0}]})})),window.addEventListener("scViewedCart",(e=>{const t=e.detail;i("view_cart",{currency:t.currency,value:t.converted_total_amount,items:(t.line_items?.data||[]).map((e=>({item_id:e?.price?.product?.id,item_name:e?.price?.product?.name,currency:e.price?.currency,discount:e?.discount_amount?e?.converted_discount_amount:0,price:e?.price?.converted_amount||0,quantity:e.quantity,...e?.variant_options?.length?{item_variant:(e.variant_options||[]).join(" / ")}:{}})))})})),window.addEventListener("scProductViewed",(e=>{const t=e.detail;i("view_item",{value:n(t.price?.amount||0,t.price?.currency||"USD"),currency:t.price?.currency,items:[{item_id:t?.id,item_name:t?.name,currency:t?.price?.currency,discount:t?.discount_amount?n(t?.discount_amount,t?.price?.currency):0,price:n(t?.price?.amount,t?.price?.currency),quantity:t?.quantity||1,...t?.variant_options?.length?{item_variant:t?.variant_options.map((e=>e.name)).join(" / ")}:{},...t?.product_collections?.data?.length?{item_category:t?.product_collections?.data?.map((e=>e.name)).join(", ")}:{}}]})}));var c=t.s;export{c as trackEvent};
Save
Back