{"version":3,"file":"default/js/gtmjs.js","sources":["webpack:///webpack/bootstrap","webpack:///./cartridges/app_site_homa/cartridge/client/default/js/gtmjs.js"],"sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = \"./cartridges/app_site_homa/cartridge/client/default/js/gtmjs.js\");\n","/**\n * Original file from app_deborla cartridge\n * Modifications:\n * - Fix eslint issues.\n * - Add documentations.\n * - Add categoryID to productGtmData.\n */\n\n'use strict';\n\nvar gtmjs = {\n init: function () {\n this.initCustomEvents();\n },\n\n initCustomEvents: function () {\n var self = this;\n\n document.addEventListener(\n 'GTM-push-addToCart',\n function (e) {\n self.pushAddToCart(e.detail.element, e.detail.quantity);\n },\n false\n );\n\n document.addEventListener(\n 'GTM-push-removeFromCart',\n function (e) {\n self.pushRemoveFromCart(e.detail.element, e.detail.quantity);\n },\n false\n );\n\n document.addEventListener(\n 'GTM-push-productDetail',\n function (e) {\n self.pushProductDetail(e.detail.element);\n },\n false\n );\n\n document.addEventListener(\n 'GTM-push-productImpressios',\n function (e) {\n self.pushProductImpressions(e.detail.elements, e.detail.list);\n },\n false\n );\n\n document.addEventListener(\n 'GTM-push-checkout',\n function (e) {\n self.pushCheckout(e.detail.step, e.detail.productsElements);\n },\n false\n );\n\n document.addEventListener(\n 'GTM-push-purchase',\n function (e) {\n self.pushPurchase(e.detail.productsElements);\n },\n false\n );\n },\n\n /**\n * Pushes the add to cart event to the dataLayer.\n * @param {Object} element - The element that contains the data attributes\n * @param {string} quantity - The quantity of the product\n */\n pushAddToCart: function (element, quantity) {\n var gtmData = element;\n\n if (!gtmData) {\n return;\n }\n\n var name = gtmData.getAttribute('data-name') || 'Name not found';\n var productId = gtmData.getAttribute('data-id') || 'Id not found';\n var price = gtmData.getAttribute('data-price') || '-.--';\n var productQuantity = quantity || '1';\n var category = gtmData.getAttribute('data-category') || 'Category not found';\n var productGtmData = {\n name: String(name),\n id: String(productId),\n price: String(price),\n quantity: String(productQuantity),\n category: String(category)\n };\n\n window.dataLayer.push({\n event: 'addToCart',\n ecommerce: {\n add: {\n products: [productGtmData]\n }\n }\n });\n },\n\n /**\n * Pushes the remove from cart event to the dataLayer.\n * @param {Object} element - The element that contains the data attributes\n * @param {string} quantity - The quantity of the product\n */\n pushRemoveFromCart: function (element, quantity) {\n var gtmData = element;\n\n if (!gtmData) {\n return;\n }\n\n var name = gtmData.getAttribute('data-name') || 'Name not found';\n var productId = gtmData.getAttribute('data-id') || 'Id not found';\n var price = gtmData.getAttribute('data-price') || '-.--';\n var productQuantity = quantity || '1';\n var category = gtmData.getAttribute('data-category') || 'Category not found';\n var productGtmData = {\n name: String(name),\n id: String(productId),\n price: String(price),\n quantity: String(productQuantity),\n category: String(category)\n };\n\n window.dataLayer.push({\n event: 'removeFromCart',\n ecommerce: {\n remove: {\n products: [productGtmData]\n }\n }\n });\n },\n\n /**\n * Pushes the product detail event to the dataLayer.\n * @param {Object} element - The element that contains the data attributes\n */\n pushProductDetail: function (element) {\n var gtmData = element;\n\n if (!gtmData) {\n return;\n }\n\n var name = gtmData.getAttribute('data-name') || 'Name not found';\n var productId = gtmData.getAttribute('data-id') || 'Id not found';\n var price = gtmData.getAttribute('data-price') || '-.--';\n var category = gtmData.getAttribute('data-category') || 'Category not found';\n var productGtmData = {\n name: String(name),\n id: String(productId),\n price: String(price),\n category: String(category)\n };\n\n window.dataLayer.push({\n event: 'productDetail',\n ecommerce: {\n detail: {\n products: [productGtmData]\n }\n }\n });\n },\n\n /**\n * Pushes the product impression event to the dataLayer.\n * @param {Object} elements - The element that contains the data attributes\n * @param {string} list - The list of products\n */\n pushProductImpressions: function (elements, list) {\n var gtmDataArray = elements;\n\n if (!gtmDataArray) {\n return;\n }\n\n var productList = [];\n\n gtmDataArray.forEach((gtmData) => {\n var name = gtmData.getAttribute('data-name') || 'Name not found';\n var productId = gtmData.getAttribute('data-id') || 'Id not found';\n var price = gtmData.getAttribute('data-price') || '-.--';\n var category = gtmData.getAttribute('data-category') || 'Category not found';\n var productGtmData = {\n name: String(name),\n id: String(productId),\n price: String(price),\n list: String(list),\n category: String(category)\n };\n\n productList.push(productGtmData);\n });\n\n window.dataLayer.push({\n event: 'productImpressions',\n ecommerce: {\n impressions: productList\n }\n });\n },\n\n /**\n * Pushes the checkout event to the dataLayer.\n * @param {Object} step - The checkout step\n * @param {Object} productsElements - The elements that contains the product data attributes\n */\n pushCheckout: function (step, productsElements) {\n var stepNumber = Number(step);\n var gtmDataArray = productsElements;\n\n if (!gtmDataArray) {\n return;\n }\n\n var dataProducts = [];\n\n gtmDataArray.forEach((gtmData) => {\n var name = gtmData.getAttribute('data-name') || 'Name not found';\n var productId = gtmData.getAttribute('data-id') || 'Id not found';\n var price = gtmData.getAttribute('data-price') || '-.--';\n var productQuantity = gtmData.getAttribute('data-quantity') || '1';\n var category = gtmData.getAttribute('data-category') || 'Category not found';\n var productGtmData = {\n name: String(name),\n id: String(productId),\n price: String(price),\n quantity: String(productQuantity),\n category: String(category)\n };\n\n dataProducts.push(productGtmData);\n });\n\n window.dataLayer.push({\n event: 'checkout',\n ecommerce: {\n checkout: {\n actionField: {\n action: 'checkout',\n step: stepNumber\n },\n products: dataProducts\n }\n }\n });\n },\n\n /**\n * Pushes the purchase event to the dataLayer.\n * @param {Object} productsElements - The elements that contains the product data attributes\n */\n pushPurchase: function (productsElements) {\n var gtmData = productsElements;\n\n if (!gtmData) {\n return;\n }\n\n var affiliation = gtmData.getAttribute('data-affiliation');\n var id = gtmData.getAttribute('data-id');\n var revenue = gtmData.getAttribute('data-revenue');\n var shipping = gtmData.getAttribute('data-shipping');\n var tax = gtmData.getAttribute('data-tax');\n var productList = gtmData.getAttribute('data-product-list');\n var productData = JSON.parse(productList);\n\n window.dataLayer.push({\n event: 'purchase',\n ecommerce: {\n purchase: {\n actionField: {\n action: 'purchase',\n affiliation: affiliation,\n id: id,\n revenue: revenue,\n shipping: shipping,\n tax: tax\n },\n products: productData\n }\n }\n });\n }\n};\n\ngtmjs.init();\n"],"mappings":";AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;AClFA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AAGA;AACA;AAIA;AAGA;AACA;AAIA;AAGA;AACA;AAIA;AAGA;AACA;AAIA;AAGA;AACA;AAIA;AAGA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AALA;AAQA;AACA;AACA;AACA;AACA;AADA;AADA;AAFA;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AALA;AAQA;AACA;AACA;AACA;AACA;AADA;AADA;AAFA;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAJA;AAOA;AACA;AACA;AACA;AACA;AADA;AADA;AAFA;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AALA;AAQA;AACA;AAEA;AACA;AACA;AACA;AADA;AAFA;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AALA;AAQA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAFA;AAIA;AALA;AADA;AAFA;AAYA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AANA;AAQA;AATA;AADA;AAFA;AAgBA;AAtRA;AAyRA;;;;A","sourceRoot":""}