*/ /* Google Tag Manager (noscript) */ const GTMNoScript = document.createElement('noscript'); const GTMNoScriptIframe = document.createElement('img'); GTMNoScriptIframe.setAttribute('src', 'https://www.googletagmanager.com/ns.html?id=GTM-5NH4RCV'); GTMNoScriptIframe.setAttribute('height', '0'); GTMNoScriptIframe.setAttribute('width', '0'); GTMNoScriptIframe.setAttribute('style', 'display:none;visibility:hidden'); GTMNoScript.appendChild(GTMNoScriptIframe); document.head.appendChild(GTMNoScript); /**/ /* End Google Tag Manager (noscript) */ /* Global site tag (gtag.js) - Google Analytics */ const gtag1Script = document.createElement('script'); gtag1Script.setAttribute('async', 'async'); gtag1Script.setAttribute('src', 'https://www.googletagmanager.com/gtag/js?id=G-DKLNNGZ186'); document.head.appendChild(gtag1Script); /**/ const gtag2Script = document.createElement('script'); gtag2Script.innerHTML = "window.dataLayer = window.dataLayer || [];\n" + "function gtag(){window.dataLayer.push(arguments);}\n" + "gtag('js', new Date());\n" + "gtag('config', 'G-DKLNNGZ186');"; document.head.appendChild(gtag2Script); /**/ const gtag3Script = document.createElement('script'); gtag3Script.innerHTML = ` const items = event.data.checkout.lineItems.map((lineItem, lineItemIndex) => { let lineLevelTotalDiscount = 0; lineItem.discountAllocations.map((discount, discountIndex) => { lineLevelTotalDiscount = lineLevelTotalDiscount + discount.amount.amount; }); if (lineLevelTotalDiscount > 0) { lineLevelTotalDiscount = lineLevelTotalDiscount / 100; } return { "item_id": \`${lineItem.variant.product.id}\`, "item_name": \`${lineItem.title}\`, "item_variant": \`${lineItem.variant.id}\`, "quantity": \`${lineItem.quantity}\`, "price": \`${lineItem.finalLinePrice.amount / 100}\`, "affiliation": \`${lineItem.variant.product.vendor}\`, "discount": \`${lineLevelTotalDiscount}\` } }); gtag('event', 'purchase', { 'send_to': 'G-DKLNNGZ186', "transaction_id": \`${event.data.checkout.order.id}\`, "affiliation": "Shopify Shopping Cart", "email":\`${event.data.checkout.email}\`, "value": \`${event.data.checkout.totalPrice.amount / 100}\`, "currency": \`${event.data.checkout.totalPrice.currencyCode}\`, "tax": \`${event.data.checkout.totalTax.amount / 100}\`, "shipping": \`${event.data.checkout.shippingLine.price / 100}\`, "items": items }); `; document.head.appendChild(gtag3Script); }); });})(self.webPixelsManager.createShopifyExtend('35160295', 'custom'));