",aw_merchant_id:"",aw_feed_country:"",aw_feed_language:"",aw_feed_label:"",handle:"",plan:false, pixels:false}, preferences: { dataLayer: null,performance: null,events: null,server: null}, plan: { handle:"",plan:false,span:0} }) =>
{
if (!options?.plan?.plan && 14 < options?.plan?.span) return Object.freeze({ track: () => {}});
(config =>
{
const enableSnippet = !(false);
let onGtm = () => { window.dispatchEvent(new CustomEvent('ec.gtm.loaded'))};
let onMeta = () => { window.dispatchEvent(new CustomEvent('ec.meta.loaded'))};
let onClarity = () => { window.dispatchEvent(new CustomEvent('ec.clarity.loaded'))};
let onTiktok = () => { window.dispatchEvent(new CustomEvent('ec.tiktok.loaded'))};
(config?.container_id && enableSnippet && !window.google_tag_manager) && (() => {(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true; j.onload = onGtm; j.src='https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);})(window,document,'script','dataLayer',config?.container_id?.trim() ); })();
(config?.meta_pixel_id !== '') && (() => {!function(f,b,e,v,n,t,s) {if(f.fbq)return;n=f.fbq=function(){n.callMethod?n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0; t.onload = onMeta; t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window, document,'script','https://connect.facebook.net/en_US/fbevents.js'); fbq('init', null); fbq('track', 'PageView'); })();
(config?.pixels?.bing?.enabled) && (() => {(function(w,d,t,r,u){var f,n,i;w[u]=w[u]||[],f=function(){var o={ti: config?.pixels?.bing?.pixel_id?.trim(), disableAutoPageView: true, enableAutoSpaTracking: false};o.q=w[u],w[u]=new UET(o),w[u].push("pageLoad")},n=d.createElement(t),n.src=r,n.async=1,n.onload=n.onreadystatechange=function(){var s=this.readyState;s&&s!=="loaded"&&s!=="complete"||(f(),n.onload=n.onreadystatechange=null)},i=d.getElementsByTagName(t)[0],i.parentNode.insertBefore(n,i)})(window,document,"script","//bat.bing.com/bat.js","uetq"); })();
(config?.pixels?.tiktok?.enabled) && (() => {!function(w,d,t) { w.TiktokAnalyticsObject=t;var ttq=w[t]=w[t]||[];ttq.methods=["page","track","identify","instances","debug","on","off","once","ready","alias","group","enableCookie","disableCookie","holdConsent","revokeConsent","grantConsent"],ttq.setAndDefer=function(t,e){t[e]=function(){t.push([e].concat(Array.prototype.slice.call(arguments,0)))}};for(var i=0;i {(function(c,l,a,r,i,t,y){c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)};t=l.createElement(r); t.onload = onClarity; t.async=1;t.src="https://www.clarity.ms/tag/"+i;y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y);})(window, document, "clarity", "script", config?.pixels?.clarity?.pixel_id);})());
Object.entries({ pixel: JSON.stringify(options), custom_pixel: '100.1.0' }).forEach(([key, value]) => { sessionStorage.setItem(key, value)});
})(options.config);
const { fetch: originalFetch } = window;
const debug = (...args) => !options?.preferences?.performance?.disable_logs && console.debug(...args);
const dispatch = (event, data, args) => document.dispatchEvent(new CustomEvent(event, { bubbles: true, cancelable: true, detail: { data, shop: { currency: "AED", options }, args } }));
window.fetch = async (...args) =>
{
let [resource, config ] = args;
let targetUrl = (resource instanceof Request) ? resource.url : resource.toString();
const response = await originalFetch(resource, config);
if (targetUrl.includes('/cart/change'))
{
response.clone().text().then(text =>
{
let data = JSON.parse(text) ?? JSON.stringify([]);
dispatch('ec.cart.change', data, args);
});
}
if (targetUrl.includes('/recommendations/products'))
{
response.clone().text().then(text =>
{
const parser = new DOMParser();
const doc = parser.parseFromString(text, "text/html");
const items = [];
let index = 1;
doc.querySelectorAll('product-card-link').forEach(link =>
{
link.querySelectorAll('product-card').forEach(card =>
{
const category = 'Recommended products';
const category_id = 'recommended_products';
items.push(
{
item_id: card?.dataset?.productId,
item_name: card.querySelector('[aria-label]')?.ariaLabel,
item_list_id: category_id,
item_list_name: category,
item_category: category,
index: index++,
price: Number(card.querySelector(".price")?.textContent?.replace(/[^0-9.]/g, "")),
quantity: 1
})
});
});
if (items.length)
{
AEC.proxy({
event: 'view_item_list',
ecommerce:
{
currency: "AED",
items: items,
}
})
}
});
}
const json = () => response.clone().json().then((data) =>
{
switch(true)
{
case -1 !== targetUrl.indexOf('/cart/add'): dispatch('ec.cart.add',data, args); break;
case -1 !== targetUrl.indexOf('/cart/update'): dispatch('ec.cart.update',data, args); break;
case -1 !== targetUrl.indexOf('storefront-api/category/product-add'): dispatch('ec.wishlist.add',data, args); break;
case -1 !== targetUrl.indexOf('storefront-api/category/product-delete'): dispatch('ec.wishlist.remove',data, args); break;
}
return data;
});
response.json = json;
return response;
};
document.addEventListener('DOMContentLoaded', () =>
{
const params = new URLSearchParams(window.location.search);
const queryParams = {};
for (const [key, value] of params.entries()) {
if (value && ['utm_source','utm_medium','utm_campaign','utm_term','utm_content'].includes(key))
{
queryParams[key] = value;
}
}
dispatch('ec.dom.loaded',
{
utm: queryParams,
preferences: options?.preferences
});
});
window.addEventListener('captured_ga_cookies', event =>
{
if (!window.captured_ga_cookies)
{
window.captured_ga_cookies = true;
fetch(window.Shopify.routes.root + 'cart/update.js',
{
method: 'POST',
headers:
{
'Content-Type': 'application/json',
},
body: JSON.stringify(
{
attributes: event.detail
}),
})
.then(response => response.json()).then(cart => {}).catch(error => console.error('Error updating cart:', error));
}
});
(function()
{
const cookies = {};
const proto = Document.prototype;
const descriptor = Object.getOwnPropertyDescriptor(proto, "cookie");
if (!descriptor || !descriptor.set)
{
return;
}
Object.defineProperty(proto, "cookie",
{
configurable: true,
enumerable: descriptor.enumerable,
get: function()
{
return descriptor.get.call(this);
},
set: function(value)
{
try
{
const name = value.split("=")[0];
let parsed_value;
switch(true)
{
case '_ga' === name:
parsed_value = value.split(';')?.shift()?.split('=')?.pop();
if (parsed_value?.startsWith('GA1.1.'))
{
cookies[name] = parsed_value;
}
break;
case -1 !== name.indexOf('_ga_'):
parsed_value = value.split(';')?.shift()?.split('=')?.pop();
if (parsed_value?.startsWith('GS2.1.'))
{
cookies[name] = parsed_value;
}
break;
}
if (2 === Object.keys(cookies).length)
{
window.dispatchEvent(new CustomEvent("captured_ga_cookies",
{
detail: cookies
}));
}
}
catch (e) {}
return descriptor.set.call(this, value);
}
});
})();
const getContext = async () =>
{
const context = await fetch("https://www.mumzmochi.com/browsing_context_suggestions.json");
const response = await context.json();
return response;
};
const get_uuid = () => 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, c => { const r = Math.random() * 16 | 0; const v = c === 'x' ? r : (r & 0x3 | 0x8); return v.toString(16); });
return {
options: options,
context: {},
google_tag_params: {},
proxy: function(data)
{
const event = data?.event;
if (event)
{
if (options?.preferences?.events?.hasOwnProperty(event))
{
if (false === options?.preferences?.events?.[event])
{
return this;
}
}
}
const reset = Number(options?.preferences?.dataLayer?.reset);
if (1 == reset)
{
dataLayer.push({ ecommerce: null });
}
dataLayer.push(data);
return this;
},
proxyTikTok: function (event, data)
{
let uuid = get_uuid();
this.TikTok.event(event, data,
{
event_id: get_uuid()
});
debug("Anowave","TikTok", event, data);
return this;
},
proxyMeta: function(event, data)
{
const fn = (data =>
{
return () => {
if (data.hasOwnProperty('content_ids'))
{
data['num_items'] = data.content_ids.length;
}
let uuid = get_uuid();
fbq('track', event, data,
{
eventID: uuid
});
sessionStorage.setItem('meta_uuid', JSON.stringify(
{
event: event,
event_id: uuid,
event_data: data,
}));
debug("Anowave","Meta Pixel", event, uuid, data);
}
})(data);
if ('undefined' !== typeof fbq)
{
fn();
}
else
{
window.addEventListener('ec.meta.loaded', () =>
{
fn();
});
}
return this;
},
track: function()
{
(context =>
{
let listeners = document.createElement('script');
listeners.onload = () =>
{
window.AnowaveListeners.attach.apply(context,[]);
};
listeners.dataset.materialize = true;
listeners.async = false;
listeners.src = "https://cdn.shopify.com/extensions/019d4427-ad0b-7f78-a89f-4835ce270d60/google-tag-manager-ga4-282/assets/listeners.js";
document.head.appendChild(listeners);
})(this);
document.addEventListener('ec.wishlist.add', event =>
{
const data = event?.detail?.data;
const args = event?.detail?.args;
const [resource, config] = Array.isArray(args) ? args : [];
if (config?.body)
{
let body = {};
try
{
body = JSON.parse(config?.body);
}
catch (e)
{
body = {};
}
const item =
{
item_id: body?.product_id
};
let payload =
{
event: 'add_to_wishlist',
ecommerce:
{
items: [item],
currency: event?.detail?.shop?.currency,
customer_id: body?.customer_id
}
};
this.proxy(payload);
}
});
document.addEventListener('ec.wishlist.remove', event =>
{
const data = event?.detail?.data;
const args = event?.detail?.args;
const [resource, config] = Array.isArray(args) ? args : [];
if (config?.body)
{
const item =
{
item_id: body?.product_id
};
let payload =
{
event: 'remove_from_wishlist',
ecommerce:
{
items: [item],
currency: event?.detail?.shop?.currency
}
};
this.proxy(payload);
}
});
document.addEventListener("DOMContentLoaded", event =>
{
document.querySelectorAll('product-card[data-product-id]').forEach(card =>
{
card.addEventListener('click', e =>
{
document.dispatchEvent(new CustomEvent('ec.select.item',
{
bubbles: true,
cancelable: true,
detail:
{
id: card.dataset.productId,
collection: null,
options: options
}
}));
});
});
document.querySelectorAll('cart-drawer-component dialog').forEach(dialog =>
{
const observer = new MutationObserver((mutationsList) =>
{
mutationsList.forEach((mutation) =>
{
if (mutation.type === 'attributes' && mutation.attributeName === 'open')
{
if (dialog.hasAttribute('open'))
{
this.trackCart();
}
}
});
});
observer.observe(dialog, { attributes: true });
});
document.querySelectorAll('input[data-variant-id]').forEach((input) =>
{
const observer = new MutationObserver((mutationsList) =>
{
mutationsList.forEach((mutation) =>
{
if (mutation.type === 'attributes' && mutation.attributeName === 'checked')
{
if (input.checked)
{
((variants, product) =>
{
const activeVariants = {};
let item = {};
document.querySelectorAll('input[data-variant-id]:checked').forEach(variant =>
{
variants.forEach(entity =>
{
if (entity?.variant_id == variant?.dataset?.variantId)
{
item = entity;
item['item_id'] = this.getProductId(product, variant?.dataset?.variantId);
activeVariants[variant?.dataset?.variantId] = item;
}
});
});
const items = [];
Object.entries(activeVariants).forEach(([key, value])=>
{
items.push(value);
});
this.proxy({
event: 'view_item',
ecommerce:
{
items: items,
currency: "AED"
}
});
})([
], null);
}
}
});
});
observer.observe(input, { attributes: true });
});
});
this.trackAll();
switch(true)
{
case -1 !== template.indexOf('page'):
case -1 !== template.indexOf('page.contact'): this.trackPage(); break;
case -1 !== template.indexOf('index'): this.trackHomepage(); break;
case -1 !== template.indexOf('collection'): this.trackCollection(); break;
case -1 !== template.indexOf('search'): this.trackSearchCollection(); break;
case -1 !== template.indexOf('product'): this.trackProduct(); break;
case -1 !== template.indexOf('cart'): this.trackCart(); break;
}
return this;
},
trackAll: function()
{
getContext().then(context =>
{
let payload =
[
{
pageType: template,
pageName: "mumz mochi",
visitorExistingCustomer: "No",
visitorLifetimeValue: 0,
visitorLoginState: "Logged out",
visitorType: "NOT LOGGED IN",
visitorCountryName: context?.detected_values?.country_name,
visitorCountryIsoCode: context?.detected_values?.country?.handle,
websiteCountry: "",
websiteLanguage: "en"
}
];
payload.push(
{
event: 'visitor_info',
customer_id: null
});
payload.forEach(data => this.proxy(data));
});
if (true)
{
document.addEventListener("DOMContentLoaded", event =>
{
document.querySelectorAll('slideshow-container').forEach(container =>
{
const items = [];
container.querySelectorAll('slideshow-slides slideshow-slide').forEach(slide =>
{
slide.querySelectorAll('product-card-link').forEach(link =>
{
items.push(
{
item_id: link?.dataset?.productId
})
});
});
if (items.length && true === options?.plan && options?.handle?.includes('pro'))
{
document.dispatchEvent(new CustomEvent('ec.slideshow.view',
{
bubbles: true,
cancelable: true,
detail: {
items: items,
domain: "www.mumzmochi.com",
token: null,
currency: "AED"
}
}));
}
});
});
}
},
trackPage: function()
{
return this;
},
trackHomepage: function()
{
document.addEventListener("DOMContentLoaded", event =>
{
const items =
[
];
if (items.length)
{
this.proxy({
event: 'view_item_list',
ecommerce:
{
currency: "AED",
items: items,
}
})
}
})
return this.trackPage();
},
trackCart: function(cart_event)
{
const eventDefault = { event: 'view_cart', eventCustom: 'ec.cart.view' };
const event = cart_event ? {...eventDefault,...cart_event} : eventDefault;
fetch('/cart.js').then(res => res.json()).then(cart =>
{
let items = [], value = 0, index = 1;
const options = {};
cart.items.forEach(item =>
{
items.push(
{
item_id: this.getProductItemId(item),
item_name: item.title,
price: item.final_price/100,
item_variant: item?.variant_title,
item_variant_id: item?.variant_id,
item_brand: item?.vendor,
quantity: item?.quantity,
sku: item?.sku,
index: index++
});
value += item?.final_line_price/100
});
document.dispatchEvent(new CustomEvent(event.eventCustom,
{
bubbles: true,
cancelable: true,
detail: {
event: event.event,
ecommerce:
{
items: items,
value: value,
currency: "AED",
},
options: options
}
}));
});
},
trackSearchCollection: function(collection)
{
},
trackCollection: function(collection)
{
},
trackRemarketing: function(google_tag_params)
{
this.google_tag_params = Object.assign(this.google_tag_params, google_tag_params);
this.proxy(
{
event: 'fireRemarketingTag',
google_tag_params: this.google_tag_params
});
},
trackProduct: function()
{
},
getItem: function (item)
{
return {
item_id: this.getProductItemId(item),
item_name: item?.product_title,
item_variant: item?.variant_title,
item_category: item?.product_type,
item_brand: item?.vendor,
item_variant_id: item?.variant_id,
price: item.presentment_price,
quantity: item.quantity,
sku: item?.sku
}
},
getItemWishlist: function(product)
{
return {
item_id: this.getProductId(product),
item_list_name: "Wishlist",
item_list_id: "Wishlist",
item_name: product?.title,
price: product?.price/100,
item_brand: product?.vendor,
item_category: product?.type,
google_business_vertical: 'retail'
}
},
getIdentifier: function()
{
return options?.preferences?.dataLayer?.identifier ?? "product.id";
},
getProductId: function(entity, current_variant_id)
{
const identifier = this.getIdentifier();
const variant_id = entity?.variants?.pop()?.id ?? null;
const default_target_country = options?.preferences?.dataLayer?.targetCountry ?? '';
const target_country = default_target_country?.length > 0 ? default_target_country.toUpperCase() : options?.config?.locale.toUpperCase();
current_variant_id = current_variant_id || null;
switch(identifier)
{
case "variant.id":
if (current_variant_id)
{
return current_variant_id;
}
if (variant_id)
{
return variant_id;
}
break;
case "product.id": return entity.id;
case "product.sku": return entity.sku;
case "shopify.google": return ['shopify', target_country, entity.id, variant_id].join('_');
}
return entity.id;
},
getProductItemId: function(item)
{
const identifier = this.getIdentifier();
switch(identifier)
{
case "variant.id": return item?.variant_id ?? item.id;
case "product.id": return item.product_id;
case "product.sku": return item?.sku ?? item.id;
case "shopify.google": return ['shopify',options?.preferences?.dataLayer?.targetCountry, item.product_id, item?.variant_id].join('_');
}
return item.product_id;
},
TikTok: (() =>
{
return {
event: (event, dataset, event_identifier) =>
{
if ('undefined' !== typeof ttq)
{
ttq.track(event, dataset, event_identifier);
}
}
}
})()
}
})("index").track();
Skip to content