vendor: 4,232 bytes, lines 1-107
1/******/ (function(modules) { // webpackBootstrap 2/******/ // The module cache 3/******/ var installedModules = {}; 4/******/ 5/******/ // The require function 6/******/ function __webpack_require__(moduleId) { 7/******/ 8/******/ // Check if module is in cache 9/******/ if(installedModules[moduleId]) { 10/******/ return installedModules[moduleId].exports; 11/******/ } 12/******/ // Create a new module (and put it into the cache) 13/******/ var module = installedModules[moduleId] = { 14/******/ i: moduleId, 15/******/ l: false, 16/******/ exports: {} 17/******/ }; 18/******/ 19/******/ // Execute the module function 20/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); 21/******/ 22/******/ // Flag the module as loaded 23/******/ module.l = true; 24/******/ 25/******/ // Return the exports of the module 26/******/ return module.exports; 27/******/ } 28/******/ 29/******/ 30/******/ // expose the modules object (__webpack_modules__) 31/******/ __webpack_require__.m = modules; 32/******/ 33/******/ // expose the module cache 34/******/ __webpack_require__.c = installedModules; 35/******/ 36/******/ // define getter function for harmony exports 37/******/ __webpack_require__.d = function(exports, name, getter) { 38/******/ if(!__webpack_require__.o(exports, name)) { 39/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); 40/******/ } 41/******/ }; 42/******/ 43/******/ // define __esModule on exports 44/******/ __webpack_require__.r = function(exports) { 45/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { 46/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); 47/******/ } 48/******/ Object.defineProperty(exports, '__esModule', { value: true }); 49/******/ }; 50/******/ 51/******/ // create a fake namespace object 52/******/ // mode & 1: value is a module id, require it 53/******/ // mode & 2: merge all properties of value into the ns 54/******/ // mode & 4: return value when already ns object 55/******/ // mode & 8|1: behave like require 56/******/ __webpack_require__.t = function(value, mode) { 57/******/ if(mode & 1) value = __webpack_require__(value); 58/******/ if(mode & 8) return value; 59/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; 60/******/ var ns = Object.create(null); 61/******/ __webpack_require__.r(ns); 62/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); 63/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); 64/******/ return ns; 65/******/ }; 66/******/ 67/******/ // getDefaultExport function for compatibility with non-harmony modules 68/******/ __webpack_require__.n = function(module) { 69/******/ var getter = module && module.__esModule ? 70/******/ function getDefault() { return module['default']; } : 71/******/ function getModuleExports() { return module; }; 72/******/ __webpack_require__.d(getter, 'a', getter); 73/******/ return getter; 74/******/ }; 75/******/ 76/******/ // Object.prototype.hasOwnProperty.call 77/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; 78/******/ 79/******/ // __webpack_public_path__ 80/******/ __webpack_require__.p = ""; 81/******/ 82/******/ 83/******/ // Load entry module and return exports 84/******/ return __webpack_require__(__webpack_require__.s = 263); 85/******/ }) 86/************************************************************************/ 87/******/ ({ 88 89/***/ 263: 90/***/ (function(module, exports) { 91 92$(document).ready(function () { 93 /** 94 * Function to trigger an event and send data to GTM. 95 * @param {string} eventName event name 96 * @param {object} dataObject of object data send to GTM 97 */ 98 function triggerGTM(eventName, dataObject) { 99 // dataLayer is a global variable that has been defined 100 dataLayer.push({ ecommerce: null }); 101 dataLayer.push({ 102 event: eventName, 103 ecommerce: dataObject 104 }); 105 } 106 107 //**************Start criteo one tag implementation with GTM*****************************//
108 let currencyCode = 'SGD'; 109 if ($('#homepage').length >= 1) { // Home page event 110 triggerGTM('criteoHomePage'); 111 } else if ($('.product-detail').length >= 1) { // Product page event 112 let pid = $('.product-detail').data('pid'); 113 let price = $('.pdp-detail-section .sales .value').attr('content'); 114 115 triggerGTM('criteoProductDetail', { 116 productDetail: { 117 pid: pid, 118 price: price, 119 isAvailable: $('.add-to-cart-custom').attr('disabled') === 'disabled' ? false : true 120 } 121 }); 122 123 } else if ($('.cart.cart-page').length > 0) { // Cart page event 124 let products = JSON.parse($('input[name=cartProductsForGtag]').val()); 125 126 triggerGTM('criteoCartPage', { 127 productList: products.map(item => ({ 128 pid: item.id, 129 price: item.price, 130 quantity: item.quantity 131 })) 132 }); 133 134 } else if ($('#product-search-results').length >= 1 && $('.product-eys-tile').length > 0) { // Listing page event 135 let queryString = $('#eys-main-page').data('querystring'); 136 let listProductId = []; 137 let productElements = $('.product-eys-tile'); 138 let catNames = $('.eys-breadcrumb .breadcrumb-item').find('span'); 139 let catHierarchy = ''; 140 let searchKeyWord = ''; 141 142 if (queryString.includes('cgid') && !queryString.includes('q=')) { 143 searchKeyWord = queryString.split('=')[1]; 144 for (let i = 1; i < catNames.length; i++) { 145 catHierarchy += (catNames.length - 1 == i) ? $(catNames[i]).text() : $(catNames[i]).text() + '>'; 146 } 147 } else { 148 searchKeyWord = queryString.split('&')[0].includes('q=') ? queryString.split('&')[0].split('=')[1] : queryString.split('&')[1].split('=')[1]; 149 } 150 151 // Select the product IDs from the first three products of listing page 152 let numberProducts = productElements.length > 3 ? 3 : productElements.length; 153 for (let i = 0; i < numberProducts; i++) { 154 let productElement = productElements[i]; 155 let pid = $(productElement).parent('.product').data('pid'); 156 listProductId.push(pid); 157 } 158 159 triggerGTM('criteoCategoryPage', { 160 categoryData: { 161 catHierarchy: catHierarchy, 162 items: listProductId, 163 catHierarchy: catHierarchy, 164 searchKeyWord: searchKeyWord 165 } 166 }); 167 168 } else if ($('#confirm-details').length >= 1) { // Confirmation page event 169 let orderId = $('#confirm-details').find('.eys-number').text(); 170 let listPro = []; 171 172 $('.order-products-table').find('tbody').find('tr').each(function () { 173 listPro.push( 174 { 175 id: $(this).find('td .procut-number').text().split(':')[1].trim(), 176 quantity: $(this).find('td .quantity').text().trim(), 177 price: $($(this).children()[2]).text().replace(/[^0-9.]/g, '') || 0 178 } 179 ); 180 }) 181 182 triggerGTM('criteoConfirmmationPage', { 183 orderData: { 184 trackTransaction: orderId, 185 items: listPro 186 } 187 }); 188 } else { 189 // Other pages, Page view event 190 triggerGTM('criteoPageView'); 191 } 192 //**************End criteo one tag implementation with GTM*****************************// 193 194 //**************Start GA4 implementation with GTM*****************************// 195 // Start Data Layer scripts when Billing Page Load 196 197 let submitPaymentButton = document.getElementById('submit-payment-button'); 198 199 // submitPaymentButton && submitPaymentButton.addEventListener('click', () => { // Avoid jquery trigger click 200 $('.submit-payment').on('click', function () { 201 let checkoutDataForGtag = $('input[name=checkoutDataForGtag]').val(); 202 checkoutDataForGtag = JSON.parse(checkoutDataForGtag); 203 204 triggerGTM('add_payment_info', { 205 checkout: checkoutDataForGtag 206 }); 207 });
208 209 // Start Data Layer scripts when Shipping Page Load 210 $('.submit-shipping').on('click', function () { 211 let checkoutDataForGtag = $('input[name=checkoutDataForGtag]').val(); 212 checkoutDataForGtag = JSON.parse(checkoutDataForGtag); 213 214 triggerGTM('add_shipping_info', { 215 checkout: checkoutDataForGtag 216 }); 217 }); 218 219 // Start Data Layer scripts for Bengin Checkout Event 220 if ($('input[name=checkoutDataForGtag]').length) { 221 let checkoutDataForGtag = $('input[name=checkoutDataForGtag]').val(); 222 checkoutDataForGtag = JSON.parse(checkoutDataForGtag); 223 224 triggerGTM('begin_checkout', { 225 checkout: checkoutDataForGtag 226 }); 227 } 228 229 // Start Data Layer scripts for Add To Cart on Product Detail Page and Quick View Page Popups 230 let addToCartGTMProductDetailPageEvent; 231 232 const addToCartGTMProductDetailPage = (me) => { 233 $(document).unbind('ajaxComplete', addToCartGTMProductDetailPageEvent); 234 235 return (_, data) => { 236 if (typeof data.responseJSON != 'undefined' && typeof data.responseJSON.error != 'undefined' && !data.responseJSON.error) { 237 let id = me.data('pid'); 238 let name = me.closest('.pdp-detail-section').find('.product-name').text(); 239 let category = me.closest('.pdp-detail-section').data('cname'); 240 let price = me.closest('.pdp-detail-section').find('.price .sales .value').attr('content'); 241 let discountedPrice = me.closest('.pdp-detail-section').find('.price .strike-through .value').attr('content'); 242 let selectedQuantity = me.closest('.attributes').find('#qtyValue_' + id).val(); 243 244 let discount = 0; 245 246 if (discountedPrice) { 247 discount = discountedPrice - price; 248 } 249 250 triggerGTM('add_to_cart', { 251 currencyCode: currencyCode, 252 add: { 253 products: [{ 254 id: id, 255 name: name, 256 category: category, 257 variant: '', 258 price: price, 259 quantity: selectedQuantity, 260 discount: discount 261 }] 262 } 263 }); 264 265 // Criteo add to cart 266 triggerGTM('criteoAddToCart', { 267 productData: [{ 268 pid: id, 269 price: price, 270 quantity: selectedQuantity 271 }] 272 }); 273 } 274 } 275 } 276 277 $('body').on('click', 'button.add-to-cart-custom', function () { 278 addToCartGTMProductDetailPageEvent = addToCartGTMProductDetailPage($(this)); 279 280 $(document).unbind('ajaxComplete', addToCartGTMProductDetailPageEvent); 281 $(document).bind('ajaxComplete', addToCartGTMProductDetailPageEvent); 282 }); 283 284 // Start Data Layer scripts for Add To Cart on Home Page 285 let addToCartGTMHomePageEvent; 286 287 const addToCartGTMHomePage = (me) => { 288 $(document).unbind('ajaxComplete', addToCartGTMHomePageEvent); 289 290 return (_, data) => { 291 if (typeof data.responseJSON != 'undefined' && typeof data.responseJSON.error != 'undefined' && !data.responseJSON.error) { 292 let id = me.closest('.add-to-cart').data('pid'); 293 294 let name = me.closest('.product-tile-body').find('.product-name-link a').text(); 295 let price = me.closest('.product-tile-body').find('.sales .value').attr('content'); 296 let discountedPrice = me.closest('.product-tile-body').find('.strike-through.list .value').attr('content'); 297 let category = me.closest('.product-tile-body').data('cname'); 298 let selectedQuantity = me.closest('.add-to-cart').find('#qtyValue_' + id).val(); 299 let discount = 0; 300 301 if (discountedPrice) { 302 discount = discountedPrice - price; 303 } 304 305 triggerGTM('add_to_cart', { 306 currencyCode: currencyCode, 307 add: { 308 products: [{ 309 id: id, 310 name: name, 311 category: category, 312 variant: '', 313 price: price, 314 quantity: selectedQuantity, 315 discount: discount 316 }] 317 } 318 }); 319 320 // Criteo add to cart 321 triggerGTM('criteoAddToCart', { 322 productData: [{ 323 pid: id, 324 price: price, 325 quantity: selectedQuantity 326 }] 327 }); 328 } 329 } 330 } 331 332 $('#homepage').on('click', 'button.tile-add-to-cart', function () { 333 addToCartGTMHomePageEvent = addToCartGTMHomePage($(this)); 334 335 $(document).unbind('ajaxComplete', addToCartGTMHomePageEvent); 336 $(document).bind('ajaxComplete', addToCartGTMHomePageEvent); 337 });
338 339 /* Start Data Layer scripts for Add To Cart on 340 the suggested products section on Product Detail Page 341 and Product Listing Page 342 and Cart Page 343 and News Page 344 and Search Page 345 */ 346 let addToCartGTMProductListPageEvent; 347 348 const addToCartGTMProductListPage = (me) => { 349 $(document).unbind('ajaxComplete', addToCartGTMProductListPageEvent); 350 351 return (_, data) => { 352 if (typeof data.responseJSON != 'undefined' && typeof data.responseJSON.error != 'undefined' && !data.responseJSON.error) { 353 let id = me.closest('.add-to-cart').data('pid'); 354 let name = me.closest('.eys-tile-body').find('.product-tile-link').text(); 355 let price = me.closest('.eys-tile-body').find('.price .sales .value').attr('content'); 356 let discountedPrice = me.closest('.eys-tile-body').find('.price .strike-through .value').attr('content'); 357 let category = me.closest('.eys-tile-body').data('cname'); 358 let selectedQuantity = me.closest('.add-to-cart').find('#qtyValue_' + id).val(); 359 let discount = 0; 360 361 if (discountedPrice) { 362 discount = discountedPrice - price; 363 } 364 365 triggerGTM('add_to_cart', { 366 currencyCode: currencyCode, 367 add: { 368 products: [{ 369 id: id, 370 name: name, 371 category: category, 372 variant: '', 373 price: price, 374 quantity: selectedQuantity, 375 discount: discount 376 }] 377 } 378 }); 379 380 // Criteo add to cart 381 triggerGTM('criteoAddToCart', { 382 productData: [{ 383 pid: id, 384 price: price, 385 quantity: selectedQuantity 386 }] 387 }); 388 } 389 } 390 } 391 392 $('#maincontent.eys-main-content').on('click', 'button.tile-add-to-cart', function () { 393 addToCartGTMProductListPageEvent = addToCartGTMProductListPage($(this)); 394 395 $(document).unbind('ajaxComplete', addToCartGTMProductListPageEvent); 396 $(document).bind('ajaxComplete', addToCartGTMProductListPageEvent); 397 }); 398 399 /* Start Data Layer scripts for Add To Cart on Wishlist Page 400 */ 401 let addToCartGTMWishlistPageEvent; 402 403 const addToCartGTMWishlistPage = (me) => { 404 $(document).unbind('ajaxComplete', addToCartGTMWishlistPageEvent); 405 406 return (_, data) => { 407 if (typeof data.responseJSON != 'undefined' && typeof data.responseJSON.error != 'undefined' && !data.responseJSON.error) { 408 let id = me.data('pid'); 409 let name = me.closest('.product-info').find('.product-tile-link').text(); 410 let price = me.closest('.product-info').find('.price .sales .value').attr('content'); 411 let discountedPrice = me.closest('.product-info').find('.price .strike-through .value').attr('content'); 412 let category = me.closest('.product-info').find('.item-attributes').data('cname'); 413 let selectedQuantity = me.closest('.product-card-price').find('#qtyValue_' + id).val(); 414 let discount = 0; 415 416 if (discountedPrice) { 417 discount = discountedPrice - price; 418 } 419 420 triggerGTM('add_to_cart', { 421 currencyCode: currencyCode, 422 add: { 423 products: [{ 424 id: id, 425 name: name, 426 category: category, 427 variant: '', 428 price: price, 429 quantity: selectedQuantity, 430 discount: discount 431 }] 432 } 433 }); 434 435 // Criteo add to cart 436 triggerGTM('criteoAddToCart', { 437 productData: [{ 438 pid: id, 439 price: price, 440 quantity: selectedQuantity 441 }] 442 }); 443 } 444 } 445 } 446 447 $('#maincontent.eys-main-content').on('click', 'button.add-to-cart-custom-wishlist', function () { 448 addToCartGTMWishlistPageEvent = addToCartGTMWishlistPage($(this)); 449 450 $(document).unbind('ajaxComplete', addToCartGTMWishlistPageEvent); 451 $(document).bind('ajaxComplete', addToCartGTMWishlistPageEvent); 452 });
453 454 // Start Data Layer scripts for Add To Wishlist on Product Detail Page and QuickView Popups 455 $('body').on('click', '.pdp-detail-section .add-to-wish-list', function (e) { 456 let pid = $(this).closest('.pdp-detail-section').find('.product-number span').text(); 457 let prodname = $(this).closest('.pdp-detail-section').find('.product-name').text(); 458 let catname = $(this).closest('.pdp-detail-section').data('cname'); 459 let priceval = $(this).closest('.pdp-detail-section').find('.price .value').attr('content'); 460 461 triggerGTM('add_to_wishlist', { 462 currencyCode: currencyCode, 463 detail: { 464 products: [{ 465 id: pid.trim(), 466 name: prodname, 467 category: catname, 468 price: priceval 469 }] 470 } 471 }); 472 }); 473 474 // Start Data Layer scripts for Add To Wishlist on View Cart Page 475 $('.cart-wishlist-block .add-to-wish-list').on('click', function (e) { 476 let pid = $(this).closest('.product-info').find('.sku .value').text(); 477 let prodname = $(this).closest('.product-info').find('.line-item-name a').text(); 478 let catname = $(this).closest('.product-info').data('cname'); 479 let priceval = $(this).closest('.product-info').find('.unit-price .price .sales .value').attr('content'); 480 481 triggerGTM('add_to_wishlist', { 482 currencyCode: currencyCode, 483 detail: { 484 products: [{ 485 id: pid, 486 name: prodname, 487 category: catname, 488 price: priceval 489 }] 490 } 491 }); 492 }); 493 494 // Start Data Layer scripts for Purchase Event 495 if ($('#confirm-details').length > 0) { 496 triggerGTM('purchase', JSON.parse($('input[name=purchaseObjectForGA]').val())); 497 } 498 499 // Start Data Layer scripts for Quickview Product 500 $('body').on('click', '.product-quickview', function () { 501 let quickViewTitle = $(this).closest('.product-eys-tile').find('.product-name-link a').text() 502 || $(this).closest('.product-image').find('.tile-image').attr('title'); 503 504 triggerGTM('quick_view', { 505 quickViewProduct: quickViewTitle 506 }); 507 }); 508 509 // Start Data Layer scripts when Click on Read More 510 $('.readmore').on('click', function () { 511 let readMoreTitle = $(this).closest('li').find('.article-heading').text().trim(); 512 if (!readMoreTitle) { 513 readMoreTitle = $(this).closest('.article-list-item').find('.article-heading span').text() 514 || $(this).closest('.beside-content').find('.article-heading span').text(); 515 } 516 517 triggerGTM('read_article', { 518 articleName: readMoreTitle 519 }); 520 }); 521 522 // Start Data Layer scripts when enter some search query 523 $('#search-suggestion-form, .no-hits-search form').on('submit', function () { 524 let searchQuery = $(this).closest('form').find('input[name=q]').val(); 525 526 triggerGTM('search_query', { 527 searchQuery: searchQuery 528 }); 529 }); 530 531 // Start Data Layer scripts for Remove From Cart on View Cart Page 532 let cartDeleteGTMEvent = () => { }; 533 534 const cartDeleteGTM = (pid, prodname, catname, priceval, selectedQuantity) => { 535 $('body').off('click', '.cart-delete-confirmation-btn', cartDeleteGTMEvent); 536 537 return () => { 538 triggerGTM('remove_from_cart', { 539 currencyCode: currencyCode, 540 remove: { 541 products: [{ 542 id: pid, 543 name: prodname, 544 category: catname, 545 variant: '', 546 price: priceval, 547 quantity: selectedQuantity 548 }] 549 } 550 }); 551 } 552 } 553 554 $('.remove-btn-lg').on('click', function () { 555 let pid = $(this).data('pid'); 556 let prodname = $(this).data('name'); 557 let catname = $(this).closest('.product-info').data('cname'); 558 let priceval = $(this).closest('.product-info').find(".line-item-total-price-amount:last").text().replace("S$", "").replace("\n", ""); 559 let cartUUID = $(this).data('uuid'); 560 let selectedQuantity = $(this).closest('.product-info').find('#quantity-' + cartUUID).val(); 561 cartDeleteGTMEvent = cartDeleteGTM(pid, prodname, catname, priceval, selectedQuantity); 562 563 $('body').off('click', '.cart-delete-confirmation-btn', cartDeleteGTMEvent); 564 $('body').on('click', '.cart-delete-confirmation-btn', cartDeleteGTMEvent); 565 });
566 567 // Start Data Layer scripts when Product Detail Page Load 568 if ($('.pdp-detail-section').length >= 1) { // Product detail page 569 let pid = $('.pdp-detail-section .product-number span').text(); 570 let prodname = $('.pdp-detail-section .product-name').text(); 571 let catname = $('.pdp-detail-section').data('cname'); 572 let priceval = $('.pdp-detail-section .price .value').attr('content'); 573 574 // View item event 575 triggerGTM('view_item', { 576 currencyCode: currencyCode, 577 detail: { 578 products: [{ 579 id: pid, 580 name: prodname, 581 category: catname, 582 variant: '', 583 price: priceval 584 }] 585 } 586 }); 587 588 // View promotion event 589 if (JSON.parse($("input[name='product-promotion-list']").val()).indexOf(pid) > -1) { 590 triggerGTM('view_promotion', { 591 promotionView: { 592 promotionId: pid, 593 promotionName: prodname, 594 listItemInPromotion: [pid] 595 } 596 }); 597 } 598 599 // Start Data Data Layer scripts for View cart event when View Cart Page Load 600 } else if ($('.cart.cart-page').length > 0) { 601 let products = $('input[name=cartProductsForGtag]').val(); 602 products = JSON.parse(products); 603 604 triggerGTM('view_cart', { 605 currencyCode: currencyCode, 606 products: products 607 }); 608 } 609 610 // Start Data Layer scripts for Review confirm event on Payment Page Load 611 $('.submit-shipping').on('click', function () { 612 let checkoutDataForGtag = $('input[name=checkoutDataForGtag]').val(); 613 checkoutDataForGtag = JSON.parse(checkoutDataForGtag); 614 615 triggerGTM('review_confirm', { 616 checkout: checkoutDataForGtag 617 }); 618 }); 619 620 // Start Data Layer scripts for Store details event when Click on Store Details 621 $('.store-detail').on('click', function () { 622 let storeName = $(this).closest('.store-info').find('.store-name').text().trim(); 623 triggerGTM('store_details', { 624 storeName: storeName 625 }); 626 }); 627 628 // Start Data Layer scripts when Click on Store Map 629 $('.store-details').closest('tr').find('.btn-primary').on('click', function () { 630 let storeName = $(this).closest('tr').find('.store-name').text().trim(); 631 triggerGTM('store_map', { 632 storeName: storeName 633 }); 634 }); 635 636 // Start Data Layer scripts on Product List Page 637 if (($('.search-results .product').length >= 1 || $('#lifestyleLandingContent').length > 0) && $('.breadcrumb .breadcrumb-item').length > 0) { 638 let productCategoryList = []; 639 let categoryUrl = $('.breadcrumb .breadcrumb-item:last').find('a').attr('href'); 640 let arrContentUrl = categoryUrl.split('/'); 641 let categoryId = arrContentUrl[arrContentUrl.length - 2]; 642 let categoryName = $('.breadcrumb .breadcrumb-item:last').find('a').text().trim(); 643 644 $('.product').each(function () { 645 productCategoryList.push({ 646 item_id: $(this).data('pid'), 647 item_name: $(this).find('.product-tile-link').text().trim() 648 }); 649 }); 650 651 // View item list event 652 triggerGTM('view_item_list', { 653 category: { 654 item_list_id: $('p.eys-search-para').length > 0 ? $('a.eys-search-suggest').attr('title').trim() : categoryId, 655 item_list_name: $('p.eys-search-para').length > 0 ? $('a.eys-search-suggest').attr('title').trim() : categoryName, 656 items: productCategoryList 657 } 658 }); 659 660 // View promotion event 661 if (JSON.parse($("input[name='category-promotion-list']").val()).indexOf(categoryId) > -1) { 662 triggerGTM('view_promotion', { 663 promotionView: { 664 promotionId: categoryId, 665 promotionName: categoryName, 666 listItemInPromotion: productCategoryList 667 } 668 }); 669 } 670 671 // Select item event 672 $(document).on('click', '.product-tile-link', function () { 673 let productId = $(this).closest('.product').data('pid'); 674 let productName = $(this).text().trim(); 675 categoryName = $(this).closest('.product-tile').find('.tile-body').data('cname'); 676 categoryId = $(this).closest('.product-tile').find('.tile-body').data('cid'); 677 678 triggerGTM('select_item', { 679 category: { 680 item_list_id: categoryId, 681 item_list_name: categoryName, 682 listItem: [{ 683 item_id: productId, 684 item_name: productName 685 }] 686 } 687 }); 688 }); 689 690 691 // Select item event (on image href) 692 $(document).on('click', 'a.js-tile', function () { 693 let productId = $(this).closest('.product').data('pid'); 694 let productName = $(this).find('img.tile-image').attr('title').trim(); 695 categoryName = $(this).closest('.product-tile').find('.tile-body').data('cname'); 696 categoryId = $(this).closest('.product-tile').find('.tile-body').data('cid'); 697 698 triggerGTM('select_item', { 699 category: { 700 item_list_id: categoryId, 701 item_list_name: categoryName, 702 listItem: [{ 703 item_id: productId, 704 item_name: productName 705 }] 706 } 707 }); 708 }); 709 710 // Start Data Layer scripts for View item list event when clicking on Load more button 711 let viewItemListForShowMoreEvent; 712 713 const viewItemListForShowMore = () => { 714 $(document).unbind('ajaxComplete', viewItemListForShowMoreEvent); 715 716 return (_, data) => { 717 if (typeof data.status != 'undefined' && data.status === 200) { 718 productCategoryList = []; 719 $('.product').each(function () { 720 if ($(this).find('.product-tile-link').text().trim()) { 721 productCategoryList.push({ 722 item_id: $(this).data('pid'), 723 item_name: $(this).find('.product-tile-link').text().trim() 724 }); 725 } 726 }); 727 // View item list event 728 triggerGTM('view_item_list', { 729 category: { 730 item_list_id: categoryId, 731 item_list_name: categoryName, 732 items: productCategoryList 733 } 734 }); 735 } 736 } 737 } 738 $('.show-more').click(function () { 739 viewItemListForShowMoreEvent = viewItemListForShowMore(); 740 741 $(document).unbind('ajaxComplete', viewItemListForShowMoreEvent); 742 $(document).bind('ajaxComplete', viewItemListForShowMoreEvent); 743 }); 744 } 745 746 // Start Data Layer scripts for Select item event (title) on Home Page 747 $('.product-name-link a').click(function () { 748 let productId = $(this).closest('.product-tile').find('.add-to-cart').data('pid'); 749 let productName = $(this).text().trim(); 750 let categoryId = $(this).closest('.product-tile').find('.product-tile-body').data('cid'); 751 let categoryName = $(this).closest('.product-tile').find('.product-tile-body').data('cname'); 752 753 triggerGTM('select_item', { 754 category: { 755 item_list_id: categoryId, 756 item_list_name: categoryName, 757 listItem: [{ 758 item_id: productId, 759 item_name: productName 760 }] 761 } 762 }); 763 });
764 765 // Start Data Layer scripts for Select item event (image) on Home Page 766 $('.product-tile-image a.product-tile-image-link').click(function () { 767 let productId = $(this).closest('.product-tile').find('.add-to-cart').data('pid'); 768 let productName = $(this).find('img.product-tile-component-image').attr('title').trim(); 769 let categoryId = $(this).closest('.product-tile').find('.product-tile-body').data('cid'); 770 let categoryName = $(this).closest('.product-tile').find('.product-tile-body').data('cname'); 771 772 triggerGTM('select_item', { 773 category: { 774 item_list_id: categoryId, 775 item_list_name: categoryName, 776 listItem: [{ 777 item_id: productId, 778 item_name: productName 779 }] 780 } 781 }); 782 }); 783 784 // Start Data Layer scripts for Select item event (image) on Also Like section 785 $(document).on('click', '.pdp-horizontal-carousel .product-tile .product-image a.js-tile', function () { 786 let productId = $(this).closest('.product-tile').find('.add-to-cart').data('pid'); 787 let productName = $(this).find('img.tile-image').attr('title').trim(); 788 let categoryId = $(this).closest('.product-tile').find('.tile-body').data('cid'); 789 let categoryName = $(this).closest('.product-tile').find('.tile-body').data('cname'); 790 791 triggerGTM('select_item', { 792 category: { 793 item_list_id: categoryId, 794 item_list_name: categoryName, 795 listItem: [{ 796 item_id: productId, 797 item_name: productName 798 }] 799 } 800 }); 801 }); 802 803 // Start Data Layer scripts for Select item event (title) on Also Like section 804 $(document).on('click', '.pdp-horizontal-carousel .product-tile a.product-tile-link', function () { 805 let productId = $(this).closest('.product-tile').find('.add-to-cart').data('pid'); 806 let productName = $(this).text().trim(); 807 let categoryId = $(this).closest('.product-tile').find('.tile-body').data('cid'); 808 let categoryName = $(this).closest('.product-tile').find('.tile-body').data('cname'); 809 810 triggerGTM('select_item', { 811 category: { 812 item_list_id: categoryId, 813 item_list_name: categoryName, 814 listItem: [{ 815 item_id: productId, 816 item_name: productName 817 }] 818 } 819 }); 820 }); 821 822 // Start Data Layer scripts for select promotion event when Click on Home Page Navigation 823 $('a.nav-link').click(function (e) { 824 let url = $(this).attr('href'); 825 if (url) { 826 let urlSplit = url.split('/'); 827 let promotionId = urlSplit[urlSplit.length - 2] ? urlSplit[urlSplit.length - 2] : ''; 828 let promotionName = $(this).html().trim(); 829 if (JSON.parse($("input[name='category-promotion-list']").val()).indexOf(promotionId) > -1) { 830 triggerGTM('select_promotion', { 831 promotion: { 832 promotion_id: promotionId, 833 promotion_name: promotionName, 834 location_id: 'homepage' 835 } 836 }); 837 } 838 } 839 }); 840 841 // Start Data Layer scripts for newsletter subscription 842 let sendNewsletterEvent; 843 844 const sendNewsletter = ($element) => { 845 $(document).unbind('ajaxComplete', sendNewsletterEvent); 846 847 return (_, data) => { 848 if (typeof data.responseJSON != 'undefined' && typeof data.responseJSON.success != 'undefined' && data.responseJSON.success) { 849 let isSuccess = false; 850 if ($element.hasClass('subscribe-email')) { 851 isSuccess = $element.parents('form').find('p.newsletter-msg.success').length > 0; 852 } else if ($element.hasClass('subscribeEmail-footer')) { 853 isSuccess = $element.parent().find('p.newsletter-msg.success').length > 0;
854 } 855 if (isSuccess) { 856 triggerGTM('newsletter_subscription', { 857 newsletter: { 858 status: 'success' 859 } 860 }); 861 } 862 } 863 } 864 } 865 866 $('button.subscribe-email, button.subscribeEmail-footer').on('click', function () { 867 sendNewsletterEvent = sendNewsletter($(this)); 868 869 $(document).unbind('ajaxComplete', sendNewsletterEvent); 870 $(document).bind('ajaxComplete', sendNewsletterEvent); 871 }); 872 873 // Start Data Layer scripts for Select item event (title) on Article Page 874 $('body').on('click', '.product-pdp-link .product-tile-link', function () { 875 let productId = $(this).closest('.product').data('pid'); 876 let productName = $(this).text().trim(); 877 categoryName = $(this).closest('.product-tile').find('.tile-body').data('cname'); 878 categoryId = $(this).closest('.product-tile').find('.tile-body').data('cid'); 879 880 triggerGTM('select_item', { 881 category: { 882 item_list_id: categoryId, 883 item_list_name: categoryName, 884 listItem: [{ 885 item_id: productId, 886 item_name: productName 887 }] 888 } 889 }); 890 }); 891 892 // Start Data Layer scripts for Select item event (image) on Article Page 893 $('body').on('click', '.product-image a.js-tile', function () { 894 let productId = $(this).closest('.product').data('pid'); 895 let productName = $(this).find('img.tile-image').attr('alt').trim();; 896 categoryName = $(this).closest('.product-tile').find('.tile-body').data('cname'); 897 categoryId = $(this).closest('.product-tile').find('.tile-body').data('cid'); 898 899 triggerGTM('select_item', { 900 category: { 901 item_list_id: categoryId, 902 item_list_name: categoryName, 903 listItem: [{ 904 item_id: productId, 905 item_name: productName 906 }] 907 } 908 }); 909 }); 910 911 //**************End GA4 implementation with GTM*****************************// 912}); 913 914 915/***/ }) 916 917/******/ });
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.