1'use strict'; 2 3var gtCurPage = window.User.clickStream; 4var userid = ''; 5var emailID_SHA1 = window.emailID_SHA1; 6var emailID = window.emailID; 7var customerNo = window.User.customerNo; 8var prodholder = new Array(); 9if (window.User.isCustomerAuthenticated == true) { 10 var userid = window.User.id; 11} else if (typeof orderCustomerNo !== 'undefined' && orderCustomerNo) { 12 customerNo = orderCustomerNo; 13} 14if (gtCurPage == 'newsletter-optin' && typeof orderConfirmation !== 'undefined') { 15 gtCurPage = 'cosummary-submit'; 16} 17 18function TrackMobileDeviceInfo(finishedObj) { 19 finishedObj.completeDeviceName = WURFL.complete_device_name; 20 finishedObj.deviceFormFactor = WURFL.form_factor; 21 finishedObj.deviceIsMobile = WURFL.is_mobile; 22} 23 24function filterArrDt(arr) { 25 var finishedArr = new Array(); 26 27 arr.forEach(function(o) { 28 if (typeof o === 'object') { 29 var finishedObj = new Object(); 30 31 Object.keys(o).forEach(function(k) { 32 if (!o[k]) { 33 return; 34 } 35 finishedObj[k] = o[k]; 36 }); 37 38 if (Object.keys(finishedObj).length > 0) { 39 finishedArr.push(finishedObj); 40 } 41 } else if (o) { 42 finishedArr.push(o); 43 } 44 }); 45 46 return finishedArr; 47} 48 49function filterDt(o) { 50 var finishedObj = {}; 51
52 Object.keys(o).forEach(function(k) { 53 if (!o[k]) { 54 } else if (o[k] instanceof Array) { 55 finishedObj[k] = filterArrDt(o[k]); 56 } else { 57 finishedObj[k] = o[k]; 58 } 59 }, this); 60 61 // Track Mobile device info 62 if (typeof WURFL !== 'undefined') { 63 TrackMobileDeviceInfo(finishedObj); 64 } 65 66 return finishedObj; 67} 68function pushDtLayer(o) { 69 window.dataLayer = window.dataLayer || []; 70 window.dataLayer.push(filterDt(o)); 71 // alert(JSON.stringify(util.filterObj(o))); 72} 73function DtgetPageCategory(pageid) { 74 //return window.pageContext.title || "Content"; ###### this throws product name 75 76 var switchval = typeof pageid == 'undefined' ? gtCurPage : pageid; 77 switch (switchval) { 78 case 'product-showincategory': 79 return 'Product Page'; 80 break; 81 case 'product-show': 82 return 'Product Page'; 83 break; 84 case 'search-show': 85 const SELECTOR_NO_HITS = '.no-hits-header'; 86 const SELECTOR_PRODUCT_TILE = '.product-tile'; 87 if (typeof searchItems != undefined && !searchItems.rs55) { 88 if (document.querySelector(SELECTOR_NO_HITS) || !document.querySelector(SELECTOR_PRODUCT_TILE)) { 89 return 'No Search Results Page'; 90 } 91 return 'General Error'; 92 } 93 if (typeof searchItems.search != undefined) { 94 if (searchItems.search) { 95 if (document.querySelector(SELECTOR_NO_HITS) || !document.querySelector(SELECTOR_PRODUCT_TILE)) { 96 return 'No Search Results Page'; 97 } 98 return 'Site Search'; 99 } else if (window.User.isContent) { 100 return 'Content'; 101 } else { 102 return 'Product List Page'; 103 } 104 } 105 return 'Product List Page'; 106 107 break; 108 case 'search-showcontent': 109 return 'Product List Page'; 110 break; 111 case 'home-show': 112 case 'default-start': 113 return 'Home Page'; 114 break; 115 case 'cart-show': 116 return 'Cart Page'; 117 break; 118 case 'cart-submitform': 119 return 'Cart Page'; 120 break; 121 case 'cart-addtowishlist': 122 return 'Cart Page'; 123 break; 124 case 'customerservice-contactus': 125 return 'Contact Customer Service'; 126 break; 127 case 'customerservice-concierge': 128 return 'Ask An Expert'; 129 break; 130 case 'account-startregister': 131 return 'My Account'; 132 break; 133 case 'account-editprofile': 134 return 'My Account'; 135 break; 136 case 'beautystation-show': 137 return 'My Account'; 138 break; 139 case 'address-list': 140 return 'My Account'; 141 break; 142 case 'paymentinstruments-list': 143 return 'My Account'; 144 break; 145 case 'wishlist-show': 146 return 'My Account'; 147 break; 148 case 'order-history': 149 return 'My Account'; 150 break; 151 case 'orderreplenishment-show': 152 return 'My Account'; 153 break; 154 case 'login-show': 155 return 'Login Page'; 156 break; 157 case 'cocustomer-start': 158 return 'Checkout'; 159 break; 160 case 'coshipping-start': 161 return 'Checkout'; 162 break; 163 case 'coshipping-singleshipping': 164 return 'Checkout'; 165 break; 166 case 'cobilling-start': 167 return 'Checkout'; 168 break; 169 case 'cobilling-billing': 170 return 'Checkout'; 171 break; 172 case 'cosinglepagecheckout-start': 173 return 'Checkout'; 174 break; 175 case 'cosummary-start': 176 return 'Checkout'; 177 break; 178 case 'giftcert-purchase': 179 return 'Gift Card Page'; 180 break; 181 case 'cocustomer-loginform': 182 return 'Customer Login'; 183 break; 184 case 'login-checkorder': 185 return 'Check Your Order'; 186 break; 187 case 'search-brandify': 188 return 'Store Locator'; 189 break; 190 case 'cosummary-submit': 191 return 'Checkout'; 192 break; 193 case 'page-show': 194 var pageurl = window.location.href; 195 if (pageurl.indexOf('customer-service.html') > 0) { 196 return 'Customer Service'; 197 } 198 if (pageurl.indexOf('concierge-form.html') > 0) { 199 return 'Ask An Expert'; 200 } 201 if (pageurl.indexOf('replenishment.html') > 0) { 202 return 'Replenishment'; 203 } 204 if (pageurl.indexOf('privacy.html') > 0) { 205 return 'Privacy Policy'; 206 } 207 if (pageurl.indexOf('terms.html') > 0) { 208 return 'Terms and Condition'; 209 } 210 if (pageurl.indexOf('returns-and-exchanges.html') > 0) { 211 return 'Returns and Exchange'; 212 } 213 if (pageurl.indexOf('staticcountryselect.html') > 0) { 214 return 'Select Country'; 215 } 216 if (pageurl.indexOf('artist-program.html') > 0) { 217 return 'Nars Pro'; 218 } 219 if (pageurl.indexOf('nars-virtual-store.html') > 0) { 220 return 'Virtual Store'; 221 } else { 222 var pagecontext = '${pageContext.title}'; 223 if (pagecontext == 'Consultations') { 224 return 'Consultation Tool'; 225 } 226 return 'Content'; 227 } 228 break; 229 case 'customerservice-submit': 230 return 'Ask An Expert'; 231 break; 232 case 'home-errornotfound': 233 return 'Error Page'; 234 break; 235 case 'login-loginform': 236 return 'Login Page'; 237 break; 238 case 'afterpayredirect-placeorder': 239 return 'Checkout'; 240 break; 241 case 'compare-show': 242 return 'Compare Tool Page'; 243 default: 244 return 'Content'; 245 break; 246 } 247} 248// Specific for checkout and cart page only 249function CouponSubCategory(pageid) { 250 var switchval = typeof pageid === 'undefined' ? gtCurPage : pageid; 251 252 switch (switchval) { 253 case 'cart-show': 254 return 'Cart'; 255 break; 256 case 'cart-submitform': 257 return 'Cart'; 258 break; 259 case 'coshipping-start': 260 return 'Shipping'; 261 break; 262 case 'coshipping-singleshipping': 263 return 'Payment'; 264 break; 265 case 'cobilling-start': 266 return 'Payment'; 267 break; 268 case 'cobilling-removegiftcertificate': 269 return 'Payment'; 270 break; 271 case 'cobilling-billing': 272 if (basketConfirmation != null) { 273 if (basketConfirmation.checkoutErrorMessage) { 274 return 'Payment'; 275 } 276 return 'Review'; 277 } 278 return 'Review'; 279 280 break; 281 case 'cosummary-submit': 282 if (typeof basketConfirmation !== 'undefined' && basketConfirmation != null) { 283 if (basketConfirmation.checkoutErrorMessage) { 284 return 'Review'; 285 } 286 } else { 287 return ''; 288 } 289 290 break; 291 case 'account-editprofile': 292 return 'Profile'; 293 break; 294 case 'address-list': 295 return 'Addresses'; 296 break; 297 case 'paymentinstruments-list': 298 return 'Payment Methods'; 299 break; 300 case 'wishlist-show': 301 return 'Saved For Later'; 302 break; 303 case 'order-history': 304 return 'Order History'; 305 break;
306 case 'orderreplenishment-show': 307 return 'Replenishment'; 308 break; 309 case 'account-startregister': 310 return 'Create Account'; 311 break; 312 case 'tutorial-show': 313 return 'Tutorial Page'; 314 break; 315 default: 316 break; 317 } 318} 319 320function DtgetPageSubcategory() { 321 return window.pageContext.title || 'Content'; 322} 323function Dtgethashmap(paramName) { 324 var output = ''; 325 326 var hashParams = window.location.hash.split('&'); 327 for (var i = 0; i < hashParams.length; i++) { 328 if (hashParams[i].indexOf(paramName) > -1) { 329 output = hashParams[i].split('=')[1]; 330 } 331 } 332 333 return output; 334} 335function DtgetLanguage() { 336 if (window.location.href.indexOf('zh.shiseido') >= 0) { 337 return 'Chinese'; 338 } 339 if (window.location.href.indexOf('es.shiseido') >= 0) { 340 return 'Spanish'; 341 } 342 return 'English'; 343} 344function DtisMobile() { 345 return $(window).width() <= 640; 346} 347function DtgetPageError() { 348 var $errorMsg = $('.error-form'); 349 if ($errorMsg.length === 0) { 350 return ''; 351 } 352 353 return $errorMsg.html().trim(); 354} 355function Dtgetsrule() { 356 var str = ''; 357 var params = ''; 358 if (window.location.href.split('?').length > 1) { 359 var urlparam = window.location.href.split('?')[1]; 360 if (urlparam.indexOf('&') > -1) { 361 params = urlparam.split('&'); 362 } else { 363 params = urlparam; 364 } 365 var length = params.length; 366 var b = length / 2; 367 368 for (var i = 0; i < b; i++) { 369 if (params[i].indexOf('srule') > -1) { 370 str = params[i].split('=')[1]; 371 } 372 } 373 } 374 return str; 375} 376// Specific for PDP 377function DtgetProductCategory() { 378 return jQuery('.breadcrumb') 379 .find('.breadcrumb-element:eq(1)') 380 .text() 381 .trim(); 382} 383// Specific for PDP 384function DtgetProductsubCategory() { 385 return $('.breadcrumb') 386 .find('.breadcrumb-element:eq(2)') 387 .text() 388 .trim(); 389} 390// Specific for PDP 391function DtgetProductsubsubCategory() { 392 return $('.breadcrumb') 393 .find('.breadcrumb-element:eq(3)') 394 .text() 395 .trim(); 396} 397function Dtgetdropdown() { 398 var str = ''; 399 if (window.location.href.split('?').length > 1) { 400 var urlparam; 401 if (window.location.href.split('?')[1].indexOf('&') > -1) { 402 urlparam = window.location.href.split('?')[1].split('&'); 403 var length = urlparam.length; 404 var prefnval, prefnkey, prefvval, prefvkey; 405 for (var i = 0; i < length; i++) { 406 var prefn = urlparam[i].indexOf('prefn'); 407 if (prefn > -1) { 408 prefnkey = urlparam[i].split('=')[0]; 409 prefnval = urlparam[i].split('=')[1]; 410 console.log(prefnkey); 411 var num = prefnkey.charAt(5); 412 for (var a = 0; a < length; a++) { 413 var prefv = urlparam[a].indexOf('prefv'); 414 prefvkey = urlparam[a].split('=')[0]; 415 if (prefvkey == 'prefv' + num) { 416 prefvval = urlparam[a].split('=')[1]; 417 str += '[' + prefnval + ':' + prefvval + ']'; 418 } 419 } 420 } 421 } 422 } 423 } 424 return str; 425} 426 427function listType() { 428 return DtgetProductCategory() == 'Search Results' ? 'search result list' : 'product category list'; 429} 430function listName() { 431 return DtgetProductCategory() == 'Search Results' ? 'Search' : DtgetProductCategory(); 432} 433// Specific for PDP 434function DtgetProductBrand() { 435 return 'Nars'; // $(".product-detail .product-brand").text(); 436} 437function getCookie(name) { 438 var re = new RegExp(name + '=([^;]+)'); 439 var value = re.exec(document.cookie); 440 return value != null ? unescape(value[1]) : null; 441} 442function DtgetCountry() { 443 var country = document.getElementById('websiteCountryCode').value; 444 return country != '' ? country : 'US'; 445} 446function Dtgeterror() { 447 switch (DtgetPageCategory()) { 448 case 'Checkout Page': 449 case 'Cart Page': 450 if (basketConfirmation != null) { 451 return basketConfirmation.checkoutErrorMessage; 452 } 453 break; 454 case 'General Error': 455 return typeof searchItems !== 'undefined' ? searchItems.error : ''; 456 break; 457 case 'Error Page': 458 return 'Page Not Found'; 459 break; 460 default: 461 break; 462 } 463} 464function receiveMessage(event) { 465 if (typeof event.data === 'object' && event.origin === 'https://hosted.where2getit.com') { 466 pushDtLayer(event.data); 467 } 468} 469function Dtgetpage() { 470 var url = window.location.href; 471 var splittedurl = url.split('?'); 472 var page = splittedurl[0].split('/'); 473 return page[page.length - 1]; 474} 475 476function getLoggedInUserAccountType() { 477 if(window.User.isExternallyAuthenticated == 'Social') { 478 if(window.User.userAcountType != null) { 479 var providerID = window.User.userAcountType;
480 if(providerID.indexOf('Google') > -1){ 481 return 'Google'; 482 } else if(providerID.indexOf('Facebook') > -1) { 483 return 'Facebook'; 484 } else if(providerID.indexOf('apple') > -1) { 485 return 'Apple'; 486 } 487 } 488 } 489 return window.User.isExternallyAuthenticated; 490} 491 492function customizeBundleProduct(productCache) { 493 let prodArr = []; 494 let product = {}; 495 product.name = productCache.name; 496 product.id = productCache.ID; 497 product.productVariantID = productCache.ID; 498 product.price = productCache.pricing.sale; 499 product.brand = productCache.brand; 500 product.productType = productCache.productType; 501 product.category = productCache.catid; 502 product.variant = productCache.size; 503 product.quantity = productCache.quantity; 504 product.productAutoReplen = productCache.productautoreplenish; 505 product.productOutofStock = productCache.productOutOfStock; 506 product.productNumReviews = productCache.productNumReviews; 507 product.productStarRating = productCache.productStarRating; 508 product.subcategory = productCache.subcategory; 509 product.subsubcategory = productCache.subsubcategory; 510 product.productColor = ''; 511 product.list = 'Bundle Page > Step 1'; 512 product.listType = sessionStorage.getItem('listType'); 513 product.listName = sessionStorage.getItem('listName'); 514 product.collectionName = productCache.brand; 515 prodArr.push(product); 516 517 return prodArr; 518} 519function getRecommendedProductStatus(productID){ 520 var recoProds= sessionStorage.getItem('recommendedproducts'); 521 if(recoProds != null && recoProds != '') { 522 var storedRecommendedProduts = JSON.parse(recoProds); 523 } 524 if(storedRecommendedProduts != undefined && storedRecommendedProduts.length > 0) { 525 if (storedRecommendedProduts.indexOf(productID) > -1) { 526 return 'recommended'; 527 } else { 528 return 'non-recommended'; 529 } 530 } else { 531 return 'non-recommended'; 532 } 533} 534 535function getRRProvider() { 536 var rrFlag= document.getElementById('rrprovider').getAttribute('data-rr-provider'); 537 return rrFlag; 538} 539/** Trigger the following datalayers after gtm.js container * */ 540// Declare a flag to indicate that the script has been executed 541var scriptExecuted; 542pageViewEvent(); 543 544// document ready 545window.addEventListener('load', function() { 546 // fire when coupon is added after page load. 547 if (DtgetPageCategory() == 'Checkout Page') { 548 var error = basketConfirmation.checkoutErrorMessage 549 ? basketConfirmation.checkoutErrorMessage 550 : $('.error-form') 551 .text() 552 .trim(); 553 var errormsgtype = ''; 554 if (error.indexOf('Payment') > -1) { 555 errormsgtype = 'Payment'; 556 } else if (error.indexOf('email') > -1) { 557 errormsgtype = 'Email'; 558 } else if (error.indexOf('Server') > -1) { 559 errormsgtype = 'Server'; 560 } 561 if (error) { 562 pushDtLayer({ 563 checkoutErrorMessage: basketConfirmation.checkoutErrorMessage 564 ? basketConfirmation.checkoutErrorMessage 565 : $('.error-form') 566 .text() 567 .trim(), 568 event: 'transactionError', 569 pageSubCategory: CouponSubCategory(), 570 pageCategory: 'Checkout Page', 571 emailhash: emailID, 572 emailHashTwo: emailID_SHA1, 573 checkoutErrorType: errormsgtype, 574 }); 575 } 576 577 if ($('.gtpromochecker').length > 0) { 578 if (!localStorage.getItem('couponvalidation')) { 579 pushDtLayer({ 580 productCoupon: $('.gtpromochecker').data('name'), 581 event: 'couponSubmission', 582 pageSubCategory: CouponSubCategory(), 583 pageCategory: DtgetPageCategory(), 584 emailhash: emailID, 585 emailHashTwo: emailID_SHA1, 586 }); 587 localStorage.couponvalidation = true; 588 } 589 } else {
590 localStorage.removeItem('couponvalidation'); 591 } 592 } 593 594 switch (gtCurPage) { 595 case 'cart-show': 596 case 'cart-addtowishlist': 597 case 'cart-submitform': 598 // fire when coupon is added after page load. 599 if ( 600 $('.gtpromochecker').length > 0 && 601 $('.rowcoupons').length > 0 && 602 $('.rowcoupons .show-for-large .bonus-item') 603 .text() 604 .trim() == 'Applied' 605 ) { 606 if (!localStorage.getItem('couponvalidation')) { 607 pushDtLayer({ 608 productCoupon: $('.gtpromochecker').data('name'), 609 event: 'couponSubmission', 610 pageSubCategory: CouponSubCategory(), 611 pageCategory: DtgetPageCategory(), 612 emailhash: emailID, 613 emailHashTwo: emailID_SHA1, 614 }); 615 localStorage.couponvalidation = true; 616 } 617 } else if ($('.gtpromochecker').length > 0 && $('.rowcoupons').length == 0) { 618 localStorage.couponvalidation = true; 619 } else { 620 localStorage.removeItem('couponvalidation'); 621 } 622 break; 623 case 'account-editprofile': 624 case 'beautystation-show': 625 // user loggedin 626 if (window.User.isRegistered && !sessionStorage.getItem('uservalidation')) { 627 if (window.User.isExternallyAuthenticated == 'Social') { 628 pushDtLayer({ 629 event: 'accountLogin', 630 userId: customerNo != null ? customerNo : null, 631 accountType: getLoggedInUserAccountType(), 632 pageSubCategory: 'Profile', 633 pageCategory: 'Account', 634 loginLocation: 'Logged in from Account', 635 }); 636 sessionStorage.setItem('uservalidation', true); 637 } else if ($('.user-info-section.content-wrap.loggedin-magic-link').length > 0) { 638 pushDtLayer({ 639 event: "accountLogin", 640 accountType: "Magic Link", 641 loginLocation: "Logged in from Account" 642 }); 643 } else { 644 pushDtLayer({ 645 event: 'accountLogin', 646 userId: customerNo != null ? customerNo : null, 647 accountType: window.User.isExternallyAuthenticated == 'Regular' ? (customerNo != null ? 'Regular' : 'Guest') : 'Social', 648 pageSubCategory: 'Profile', 649 pageCategory: 'Account', 650 emailhash: emailID, 651 emailHashTwo: emailID_SHA1, 652 loginLocation: 'Logged in from Account', 653 }); 654 sessionStorage.setItem('uservalidation', true); 655 } 656 } 657 658 // Account Registration 659 if ((window.Resources.ACCOUNT_REGISTRATION != null) && (window.Resources.ACCOUNT_REGISTRATION != 'null')) { 660 pushDtLayer({ 661 event: 'accountCreation', 662 userId: customerNo != null ? customerNo : null, 663 accountType: window.User.isExternallyAuthenticated == 'Regular' ? (customerNo != null ? 'Regular' : 'Guest') : 'Facebook', 664 pageSubCategory: 'Profile', 665 pageCategory: 'Account', 666 emailhash: emailID, 667 emailHashTwo: emailID_SHA1, 668 }); 669 670 fbq('track', 'CompleteRegistration'); 671 } 672 if (window.Resources.SOCIAL_ACCOUNT_REGISTRATION) { 673 pushDtLayer({ 674 event: 'accountCreation', 675 userId: customerNo != null ? customerNo : null, 676 accountType: getLoggedInUserAccountType(), 677 pageSubCategory: 'Profile', 678 pageCategory: 'Account', 679 loginLocation: 'Logged in from Account', 680 }); 681 } 682 683 break; 684 685 case 'coshipping-start': 686 if (window.User.isCustomerAuthenticated && !sessionStorage.getItem('uservalidation')) { 687 pushDtLayer({ 688 event: 'accountLogin', 689 userId: customerNo != null ? customerNo : null, 690 accountType: window.User.isExternallyAuthenticated == 'Regular' ? (customerNo != null ? 'Regular' : 'Guest') : 'Facebook', 691 pageSubCategory: 'Login', 692 pageCategory: 'Checkout', 693 emailhash: emailID, 694 emailHashTwo: emailID_SHA1, 695 loginLocation: 'Logged in inside checkout', 696 }); 697 sessionStorage.setItem('uservalidation', true); 698 } 699 break; 700 case 'page-show': 701 if ( 702 DtgetPageCategory() == 'Nars Pro' && 703 window.User.isCustomerAuthenticated && 704 !sessionStorage.getItem('uservalidation') 705 ) { 706 pushDtLayer({ 707 event: 'accountLogin', 708 userId: customerNo != null ? customerNo : null, 709 accountType: window.User.isExternallyAuthenticated == 'Regular' ? (customerNo != null ? 'Pro-Program' : 'Guest') : 'Facebook', 710 pageSubCategory: 'Login', 711 pageCategory: 'Nars Pro', 712 emailhash: emailID, 713 emailHashTwo: emailID_SHA1, 714 loginLocation: 'Logged in outside checkout', 715 }); 716 sessionStorage.setItem('uservalidation', true); 717 } 718 719 // Account Registration 720 if (typeof window.Resources !== 'undefined' && window.Resources.ACCOUNT_REGISTRATION == 'true') { 721 pushDtLayer({ 722 event: 'accountCreation', 723 userId: customerNo != null ? customerNo : null, 724 accountType: window.User.isExternallyAuthenticated == 'Regular' ? (customerNo != null ? 'Pro-Program' : 'Guest') : 'Facebook', 725 pageSubCategory: 'Login', 726 emailhash: emailID, 727 emailHashTwo: emailID_SHA1, 728 pageCategory: 'Nars Pro', 729 }); 730 731 fbq('track', 'CompleteRegistration'); 732 } 733 break; 734 735 case 'cosinglepagecheckout-start': 736 if ($('.spc-orderconfirmation-div.login-user.loggedin-magic-link').length > 0) { 737 pushDtLayer({ 738 event: "accountLogin", 739 accountType: "Magic Link", 740 loginLocation: "Logged in from Account" 741 }); 742 } else if (window.Resources.SOCIAL_ACCOUNT_REGISTRATION) { 743 pushDtLayer({ 744 event: 'accountCreation', 745 userId: customerNo != null ? customerNo : null, 746 accountType: getLoggedInUserAccountType(), 747 pageSubCategory: 'Login', 748 pageCategory: 'Checkout', 749 loginLocation: 'Checkout', 750 }); 751 } else if (window.User.isRegistered && !sessionStorage.getItem('uservalidation')){ 752 pushDtLayer({ 753 event: 'accountLogin', 754 userId: customerNo != null ? customerNo : null, 755 accountType: getLoggedInUserAccountType() == 'Regular' ? (customerNo != null ? 'Regular' : 'Guest') : getLoggedInUserAccountType(), 756 pageSubCategory: 'Login', 757 pageCategory: 'Checkout', 758 loginLocation: 'Checkout' 759 });
760 sessionStorage.setItem('uservalidation', true); 761 } 762 763 break; 764 default: 765 break; 766 } 767}); 768 769switch (gtCurPage) { 770 case 'cart-show': 771 case 'cart-addtowishlist': 772 case 'cart-submitform': 773 // car show data layer 774 var loadedonCartpage; 775 if (typeof basketConfirmation !== 'undefined' && basketConfirmation !== null && !loadedonCartpage) { 776 loadedonCartpage = true; 777 pushDtLayer({ 778 event: 'view_cart', 779 checkoutErrorMessage: basketConfirmation.checkoutErrorMessage, 780 giftWrapping: basketConfirmation.giftWrapping, 781 pageSubCategory: 'Cart', 782 emailhash: emailID, 783 emailHashTwo: emailID_SHA1, 784 funnelType: basketConfirmation.funnelType, 785 eeAction: 'eeCheckout', 786 checkoutStep: '1', 787 productOrderType: basketConfirmation.productOrderType, 788 pageCategory: 'Checkout', 789 products: basketConfirmation.productLineItems, 790 }); 791 } 792 793 break; 794 case 'cocustomer-loginform': 795 if (typeof basketConfirmation !== 'undefined' && basketConfirmation !== null) { 796 pushDtLayer({ 797 checkoutErrorMessage: basketConfirmation.checkoutErrorMessage, 798 giftWrapping: basketConfirmation.giftWrapping, 799 pageSubCategory: 'Cart', 800 funnelType: basketConfirmation.funnelType, 801 eeAction: 'eeCheckout', 802 checkoutStep: '2', 803 productOrderType: basketConfirmation.productOrderType, 804 pageCategory: 'Checkout', 805 products: basketConfirmation.productLineItems, 806 }); 807 } 808 break; 809 case 'cocustomer-start': 810 // populate data layer for checkout login page 811 if (typeof basketConfirmation !== 'undefined' && basketConfirmation !== null) { 812 pushDtLayer({ 813 checkoutErrorMessage: basketConfirmation.checkoutErrorMessage, 814 giftWrapping: basketConfirmation.giftWrapping, 815 pageSubCategory: 'Login', 816 funnelType: basketConfirmation.funnelType, 817 eeAction: 'eeCheckout', 818 checkoutStep: '2', 819 productOrderType: basketConfirmation.productOrderType, 820 pageCategory: 'Checkout', 821 emailhash: emailID, 822 emailHashTwo: emailID_SHA1, 823 products: basketConfirmation.productLineItems, 824 }); 825 } 826 break; 827 case 'cosinglepagecheckout-start': 828 // populate data layer for OPC shipping 829 let checkoutPageLoadStep = true; 830 if (typeof spcCheckoutStep != 'undefined' && spcCheckoutStep == '4.0') { 831 checkoutPageLoadStep = false; 832 } 833 var URLParams = window.location.search.substring(1).split('&'); 834 var isFourthStepPaypal = URLParams.includes('SPCPMRedirectUrlSteps=fourth') && basketConfirmation.paymentMethod.includes('PayPal'); 835 if (checkoutPageLoadStep && typeof basketConfirmation !== 'undefined' && basketConfirmation !== null && !isFourthStepPaypal) { 836 sessionStorage.setItem('checkoutVersionType', 'OPC'); 837 pushDtLayer({ 838 checkoutErrorMessage: basketConfirmation.checkoutErrorMessage, 839 giftWrapping: basketConfirmation.giftWrapping, 840 pageSubCategory: 'Shipping',
841 funnelType: basketConfirmation.funnelType, 842 eeAction: 'eeCheckout', 843 checkoutStep: '3', 844 productOrderType: basketConfirmation.productOrderType, 845 pageCategory: 'Checkout', 846 checkoutVersion: 'One page checkout', 847 products: basketConfirmation.productLineItems, 848 conversion_location: window.metaCheckout, 849 }); 850 } else if (isFourthStepPaypal) { 851 if (checkoutPageLoadStep) { 852 sessionStorage.setItem('checkoutVersionType', 'OPC'); 853 var couponCode = ''; 854 for (var i = 0; i < basketConfirmation.coupons.length; i++) { 855 if (basketConfirmation.coupons[i]) { 856 couponCode += basketConfirmation.coupons[i] + ','; 857 } 858 } 859 if (couponCode.length > 0) { 860 couponCode = couponCode.substr(0, couponCode.length - 1); 861 } 862 var pageUrl = '/checkout/order-review'; 863 864 if (User.locale != null && User.locale != undefined) { 865 if (User.locale == 'en_CA') { 866 pageUrl = '/ca/en/checkout/order-review'; 867 } else if (User.locale == 'fr_CA') { 868 pageUrl = '/ca/fr/checkout/order-review'; 869 } 870 } 871 pushDtLayer({ 872 eeAction: 'eeCheckout', 873 event: 'virtualPageview', 874 page: pageUrl, 875 checkoutStep: '5', 876 funnelType: basketConfirmation.funnelType, 877 giftWrapping: basketConfirmation.giftWrapping, 878 checkoutErrorMessage: basketConfirmation.checkoutErrorMessage, 879 pageCategory: 'Checkout', 880 pageSubCategory: 'Review', 881 checkoutVersion: 'One page checkout', 882 couponCode: couponCode, 883 paymentType: basketConfirmation.paymentMethod.includes('PayPal') ? sessionStorage.getItem('PayPalSource') ? sessionStorage.getItem('PayPalSource'): basketConfirmation.paymentMethod.join("/"): basketConfirmation.paymentMethod.join("/"), 884 products: basketConfirmation.productLineItems, 885 }); 886 } 887 } 888 break; 889 case 'coshipping-start': 890 // populate data layer for shipping 891 if (typeof basketConfirmation !== 'undefined' && basketConfirmation !== null) { 892 pushDtLayer({ 893 checkoutErrorMessage: basketConfirmation.checkoutErrorMessage, 894 giftWrapping: basketConfirmation.giftWrapping, 895 pageSubCategory: CouponSubCategory(), 896 emailhash: emailID, 897 emailHashTwo: emailID_SHA1, 898 funnelType: basketConfirmation.funnelType, 899 eeAction: 'eeCheckout', 900 checkoutStep: '3', 901 productOrderType: basketConfirmation.productOrderType, 902 pageCategory: 'Checkout', 903 checkoutVersion: 'Legacy Checkout', 904 products: basketConfirmation.productLineItems, 905 }); 906 } 907 break; 908 case 'coshipping-singleshipping': 909 // populate data layer for successful billing 910 if (typeof basketConfirmation !== 'undefined' && basketConfirmation !== null) { 911 pushDtLayer({ 912 checkoutErrorMessage: basketConfirmation.checkoutErrorMessage, 913 giftWrapping: basketConfirmation.giftWrapping, 914 pageSubCategory: CouponSubCategory(), 915 funnelType: basketConfirmation.funnelType, 916 eeAction: 'eeCheckout', 917 checkoutVersion: 'Legacy Checkout', 918 checkoutStep: '4', 919 productOrderType: basketConfirmation.productOrderType, 920 pageCategory: 'Checkout', 921 emailhash: emailID, 922 emailHashTwo: emailID_SHA1, 923 products: basketConfirmation.productLineItems, 924 }); 925 pushDtLayer({ 926 event: 'eeCheckoutOption', 927 checkoutStep: '3', 928 emailhash: emailID, 929 emailHashTwo: emailID_SHA1, 930 checkoutOption: basketConfirmation.defaultShipping, 931 }); 932 } 933 break; 934 case 'cobilling-billing': 935 case 'cobilling-start': 936 // populate data layer for successful billing 937 if (typeof basketConfirmation !== 'undefined' && basketConfirmation !== null) { 938 var pageSubCategory = CouponSubCategory();
939 var checkoutStep; 940 var eventStep; 941 if (pageSubCategory == 'Payment') { 942 checkoutStep = '4'; 943 eventStep = '3'; 944 } else { 945 checkoutStep = '5'; 946 eventStep = '4'; 947 } 948 pushDtLayer({ 949 checkoutErrorMessage: basketConfirmation.checkoutErrorMessage, 950 giftWrapping: basketConfirmation.giftWrapping, 951 pageSubCategory: pageSubCategory, 952 funnelType: basketConfirmation.funnelType, 953 eeAction: 'eeCheckout', 954 checkoutStep: checkoutStep, 955 productOrderType: basketConfirmation.productOrderType, 956 pageCategory: 'Checkout', 957 checkoutVersion: 'Legacy Checkout', 958 emailhash: emailID, 959 emailHashTwo: emailID_SHA1, 960 products: basketConfirmation.productLineItems, 961 }); 962 pushDtLayer({ 963 event: 'eeCheckoutOption', 964 checkoutStep: eventStep, 965 emailhash: emailID, 966 emailHashTwo: emailID_SHA1, 967 checkoutOption: basketConfirmation.paymentMethod, 968 }); 969 } 970 break; 971 case 'cosummary-submit': 972 case 'coplaceorder-submit': 973 case 'afterpayredirect-placeorder': 974 case 'cosummary-showconfirmation': 975 case 'shoprunner-setupconfirmation': 976 // populate data layer for sucessful transaction 977 if (typeof orderConfirmation !== 'undefined') { 978 var checkoutVersion; 979 if ( 980 sessionStorage.getItem('checkoutVersionType') && 981 sessionStorage.getItem('checkoutVersionType') === 'OPC' 982 ) { 983 checkoutVersion = 'One Page Checkout'; 984 } else { 985 checkoutVersion = 'Legacy Checkout'; 986 } 987 if (sessionStorage.getItem('spcheckoutv2') == 'true') { 988 checkoutVersion = 'Vertical Checkout'; 989 sessionStorage.removeItem('spcheckoutv2'); 990 } 991 // the push must be placed before the gtm.js container call 992 var tansactionCouponCode = ''; 993 for (var i = 0; i < orderConfirmation.coupons.length; i++) { 994 if (orderConfirmation.coupons[i]) { 995 tansactionCouponCode += orderConfirmation.coupons[i] + ','; 996 } 997 } 998 if (tansactionCouponCode.length > 0) { 999 tansactionCouponCode = tansactionCouponCode.substr(0, tansactionCouponCode.length - 1); 1000 } 1001 for (var i = 0; i < orderConfirmation.productLineItems.length; i++) { 1002 orderConfirmation.productLineItems[i].recommendedProduct = getRecommendedProductStatus(orderConfirmation.productLineItems[i].productVariantID); 1003 } 1004 var paymentType = ''; 1005 if (orderConfirmation.paymentMethod) { 1006 if (orderConfirmation.paymentMethod === 'AFTERPAY_PBI') { 1007 paymentType = 'After Pay'; 1008 } else if (orderConfirmation.paymentMethod == "ApplePay") { 1009 paymentType = orderConfirmation.paymentMethod + sessionStorage.applePayLoc; 1010 } else if (orderConfirmation.paymentMethod === 'PayPal' && sessionStorage.getItem('PayPalSource')) { 1011 paymentType = sessionStorage.getItem('PayPalSource'); 1012 } else { 1013 paymentType = orderConfirmation.paymentMethod; 1014 } 1015 } 1016 pushDtLayer({ 1017 event: 'purchase', 1018 transactionId: orderConfirmation.transactionId, 1019 transactionShipping: orderConfirmation.transactionShipping, 1020 transactionTotal: orderConfirmation.adjMerchandizeTotalNet, 1021 transactionCoupon: orderConfirmation.transactionCoupon, 1022 transactionTax: orderConfirmation.tax, 1023 paymentType: paymentType, 1024 shippingType: orderConfirmation.defaultShipping, 1025 currencyCode: orderConfirmation.currencyCode, 1026 transactionTotalWithoutCoupon: orderConfirmation.merchandizeTotalNet, 1027 giftWrapping: orderConfirmation.giftWrapping, 1028 pageSubCategory: 'Confirmation', 1029 funnelType: orderConfirmation.funnelType, 1030 productOrderType: orderConfirmation.productOrderType, 1031 pageCategory: 'Checkout', 1032 checkoutVersion: checkoutVersion, 1033 emailhash: emailID, 1034 emailHashTwo: emailID_SHA1, 1035 products: orderConfirmation.productLineItems, 1036 orderDiscount: orderConfirmation.orderDiscount, 1037 couponCode: tansactionCouponCode, 1038 orderType: orderConfirmation.orderType, 1039 conversion_location: window.metaCheckout, 1040 }); 1041 } 1042 break; 1043 case 'search-show': 1044 if (typeof searchItems !== 'undefined' && searchItems.search) { 1045 pushDtLayer({ 1046 cat55: sessionStorage.getItem('mobilesearch') ? 'Site Search Hamburger Menu' : 'Site Search', 1047 pageCategory: DtgetPageCategory(), 1048 emailhash: emailID, 1049 emailHashTwo: emailID_SHA1, 1050 kw55: searchItems.kw55, 1051 }); 1052 1053 pushDtLayer({ 1054 res55: searchItems.rs55, 1055 emailhash: emailID, 1056 emailHashTwo: emailID_SHA1, 1057 pageCategory: DtgetPageCategory(), 1058 }); 1059 } 1060 1061 // plp/search pageview 1062 /* if(typeof productData !== "undefined"){ 1063 pushDtLayer({ 1064 "event": "eeListView", 1065 "eeAction": "eeListView", 1066 "pageCategory": searchItems.search ? "Site Search" :"Product List Page", 1067 "emailHashTwo": emailID_SHA1, 1068 "dropDown": "", 1069 "filterChoice": "", 1070 "currencyCode" : window.User.currencyCode, 1071 "products": productData.product || new Array() 1072 }); 1073 prodholder.push(productData.product); 1074 } */ 1075 break;
1076 case 'product-showincategory': 1077 case 'product-show': 1078 var products = new Array(); 1079 var product = null; 1080 // product detail page load page 1081 if (DtgetPageCategory() == 'Product Page' && productCache.length > 1) { 1082 for (var i = 0, len = productCache.length; i < len; i++) { 1083 if (!productCache[i].isCustomizableBundle) { 1084 product = { 1085 listType: sessionStorage.getItem('listType'), 1086 listName: sessionStorage.getItem('listName'), 1087 id: productCache[i].variant ? productCache[i].masterID : productCache[i].ID, 1088 productVariantID: productCache[i].master ? productCache[i].defalutvariant : productCache[i].ID, 1089 category: 1090 productCache[i].catid + 1091 '/' + 1092 productCache[i].subcategory + 1093 '/' + 1094 productCache[i].subsubcategory, 1095 price: 1096 typeof productCache[i].pricing !== 'undefined' 1097 ? productCache[i].pricing.sale 1098 ? productCache[i].pricing.sale 1099 : productCache[i].pricing.minprice 1100 : '', 1101 name: productCache[i].name, 1102 brand: productCache[i].brand, 1103 quantity: productCache[i].quantity, 1104 size: productCache[i].size, 1105 subCategory: productCache[i].subcategory, 1106 subSubCategory: productCache[i].subsubcategory, 1107 productAutoReplen: productCache[i].productautoreplenish, 1108 productOutOfStock: productCache[i].productOutOfStock,
1109 productColor: productCache[i].productColor, 1110 productType: 1111 productCache[i].productType == 'e-Gift Card' ? productCache[i].productType : 'Product', 1112 productNumReviews: productCache[i].productNumReviews, 1113 productStarRating: productCache[i].productStarRating, 1114 lastChance : productCache[i].lastChance, 1115 productLiveDate : productCache[i].productLiveDate, 1116 "new" : productCache[i].new, 1117 listType: sessionStorage.getItem('listType'), 1118 listName: sessionStorage.getItem('listName') 1119 }; 1120 } 1121 products.push(product); 1122 } 1123 } 1124 if (DtgetPageCategory() == 'Product Page' && !(productCache.length > 1) && !productCache.isCustomizableBundle) { 1125 product = { 1126 id: productCache.variant ? productCache.masterID : productCache.ID, 1127 productVariantID: productCache.master ? productCache.defalutvariant : productCache.ID, 1128 category: productCache.catid, 1129 price: 1130 typeof productCache.pricing !== 'undefined' 1131 ? productCache.pricing.sale 1132 ? productCache.pricing.sale 1133 : productCache.pricing.minprice 1134 : '', 1135 name: productCache.masterName, 1136 brand: productCache.brand, 1137 quantity: productCache.quantity, 1138 variant: productCache.size, 1139 subCategory: productCache.subcategory, 1140 subSubCategory: productCache.subsubcategory, 1141 productAutoReplen: productCache.productautoreplenish, 1142 productOutOfStock: productCache.productOutOfStock, 1143 productColor: productCache.productColor, 1144 productType: productCache.productType == 'e-Gift Card' ? productCache.productType : productCache.customProductType == 'Bundle' ? productCache.customProductType : 'Product', 1145 productNumReviews: productCache.prodNumReviews, 1146 productStarRating: productCache.prodStarRating, 1147 recommendedProduct: getRecommendedProductStatus(productCache.ID), 1148 collectionName: productCache.customBrand, 1149 lastChance : productCache.lastChance, 1150 productLiveDate : productCache.productLiveDate, 1151 "new" : productCache.new, 1152 listType: sessionStorage.getItem('listType'), 1153 listName: sessionStorage.getItem('listName'), 1154 }; 1155 products.push(product); 1156 } 1157 let availableTool = productCache.availableTool 1158 if(productCache.master) { 1159 availableTool = productCache.defalutvariantVTOEnable ? 'Virtual Try On' : availableTool; 1160 } 1161 if (products.length > 0) { 1162 if(!window.shadeFinderClicked && !window.productDetailPushed){ 1163 window.productDetailPushed = true; 1164 pushDtLayer({ 1165 event: 'view_item', 1166 eeAction: 'eeProductDetail', 1167 pageCategory: 'Product Page', 1168 availableTool: availableTool, 1169 pageCategory: productCache.productType == 'e-Gift Card' ? 'Gift Card' : 'Product Page', 1170 products: products, 1171 }); 1172 } 1173 } 1174 1175 if (!(productCache.length > 1) && productCache.isCustomizableBundle) { 1176 let bundleProduct = customizeBundleProduct(productCache); 1177 pushDtLayer({ 1178 event: 'view_item', 1179 eeAction: 'eeProductDetail', 1180 pageCategory: 'Product Page', 1181 products: bundleProduct, 1182 }); 1183 } 1184 1185 if (typeof $BV !== 'undefined') { 1186 $BV.configure('global', { 1187 events: { 1188 submissionSubmitted: function(data) { 1189 // NEW Request fix for submit question in PDP 1190 if ($(".bv-submission-button-submit:contains('Post Question')").length > 0) { 1191 pushDtLayer({ 1192 page: Dtgetpage(), 1193 event: 'submitQuestion', 1194 productCategory: DtgetProductCategory(), 1195 question: $('#bv-textarea-field-questionsummary').val(), 1196 productName: productCache.name, 1197 pageSubCategory: 'Ask a Question', 1198 emailhash: emailID, 1199 emailHashTwo: emailID_SHA1, 1200 pageCategory: 'Product Page', 1201 }); 1202 } 1203 // NEW Request fix for submit review in PDP 1204 var submitbutotnlabel = document.getElementsByClassName('bv-submission-button-submit'); 1205 if (submitbutotnlabel.length > 0) { 1206 var submitbutotnlabeltext = submitbutotnlabel[0].innerText.toLowerCase(); 1207 if (submitbutotnlabeltext == 'post review') { 1208 pushDtLayer({ 1209 event: 'submitReview', 1210 productCategory: DtgetProductCategory(), 1211 productSubCategory: DtgetProductsubCategory(), 1212 pageSubCategory: 'Reviews', 1213 productName: productCache.name, 1214 emailhash: emailID, 1215 emailHashTwo: emailID_SHA1, 1216 pageCategory: 'Product Page', 1217 productId: data.Id, 1218 }); 1219 } 1220 } 1221 }, 1222 }, 1223 }); 1224 } 1225 break; 1226 case 'search-brandify': 1227 // var pageCat=$("#lastPageVisited").val(); 1228 var pageCat = document.getElementById('lastPageVisited').value; 1229 1230 pushDtLayer({ 1231 event: 'storeLocator', 1232 pageCategory: localStorage.getItem('storelocatorpagecat'), 1233 emailhash: emailID, 1234 emailHashTwo: emailID_SHA1, 1235 pageSubCategory: 1236 localStorage.getItem('storelocatorpagesubcat') == 'undefined' 1237 ? '' 1238 : localStorage.getItem('storelocatorpagesubcat'), 1239 }); 1240 1241 // deleting storage values of previous page cateogry and subcategory 1242 localStorage.removeItem('storelocatorpagecat'); 1243 localStorage.removeItem('storelocatorpagesubcat'); 1244 1245 window.addEventListener('message', receiveMessage); 1246 break; 1247 default: 1248 break; 1249} 1250 1251 1252 1253// Navigation click 1254function pageViewEvent() { 1255 if (typeof searchItems !== 'undefined') { 1256 if (searchItems.error === 'Page Not Found') { 1257 pushDtLayer({ 1258 event: 'page_view', 1259 userId: customerNo != null ? customerNo : null, 1260 language: DtgetLanguage(), 1261 websiteCountry: DtgetCountry(), 1262 pageCategory: 'Error Page', 1263 pageSubCategory: '', 1264 emailhash: emailID, 1265 emailHashTwo: emailID_SHA1, 1266 navigationLinkClicked: sessionStorage.getItem('navlink') ? '1' : '0', 1267 navigationLinkNameClicked: sessionStorage.getItem('navlink'), 1268 navigationLocationClicked: sessionStorage.getItem('menuloc'), 1269 pageError: searchItems.error, 1270 dropDown: '', 1271 filterChoice: '', 1272 productUpdate: sessionStorage.getItem('productUpdate') ? '1' : '0', 1273 }); 1274 } else if (DtgetPageCategory() == 'Product List Page') { 1275 if ( 1276 searchItems.lastclk == 'account-editprofile' || 1277 searchItems.lastclk == 'address-list' || 1278 searchItems.lastclk == 'paymentinstruments-list' || 1279 searchItems.lastclk == 'wishlist-show' || 1280 searchItems.lastclk == 'order-history' ||
1281 searchItems.lastclk == 'orderreplenishment-show' || 1282 searchItems.lastclk == 'customerservice-contactus' 1283 ) { 1284 pushDtLayer({ 1285 event: 'page_view', 1286 userId: customerNo != null ? customerNo : null, 1287 language: DtgetLanguage(), 1288 websiteCountry: DtgetCountry(), 1289 pageCategory: DtgetPageCategory(), 1290 pageSubCategory: CouponSubCategory(), 1291 emailhash: emailID, 1292 emailHashTwo: emailID_SHA1, 1293 navigationLinkClicked: getCookie('navdata') ? '1' : '0', 1294 navigationLinkNameClicked: sessionStorage.getItem('navlink') 1295 ? sessionStorage.getItem('navlink') 1296 : getCookie('navdata'), 1297 navigationLocationClicked: 'topmenu', 1298 pageError: Dtgeterror(), 1299 dropDown: '', 1300 filterChoice: '', 1301 productUpdate: sessionStorage.getItem('productUpdate') ? '1' : '0', 1302 }); 1303 } else { 1304 1305 // Retrieve the value of navlink from localStorage (if present) 1306 if(localStorage.navlink){ 1307 var gtmNavData = localStorage.getItem('navlink'); 1308 sessionStorage.setItem('navlink', gtmNavData); 1309 // Clear the value of navlink from localStorage 1310 localStorage.removeItem('navlink'); 1311 } 1312 1313 pushDtLayer({ 1314 event: 'page_view', 1315 userId: customerNo != null ? customerNo : null, 1316 language: DtgetLanguage(), 1317 websiteCountry: DtgetCountry(), 1318 pageCategory: DtgetPageCategory(), 1319 pageSubCategory: CouponSubCategory(), 1320 emailhash: emailID, 1321 emailHashTwo: emailID_SHA1, 1322 navigationLinkClicked: sessionStorage.getItem('navlink') ? '1' : '0', 1323 navigationLinkNameClicked: sessionStorage.getItem('navlink'), 1324 navigationLocationClicked: sessionStorage.getItem('menuloc'), 1325 pageError: Dtgeterror(), 1326 dropDown: '', 1327 filterChoice: '', 1328 productUpdate: sessionStorage.getItem('productUpdate') ? '1' : '0', 1329 }); 1330 } 1331 } else if (gtCurPage == 'customerservice-contactus') { 1332 pushDtLayer({ 1333 event: 'page_view', 1334 userId: customerNo != null ? customerNo : null, 1335 language: DtgetLanguage(), 1336 websiteCountry: DtgetCountry(), 1337 pageCategory: DtgetPageCategory(), 1338 emailhash: emailID, 1339 emailHashTwo: emailID_SHA1, 1340 pageSubCategory: CouponSubCategory(), 1341 navigationLinkClicked: '0', 1342 navigationLinkNameClicked: '', 1343 navigationLocationClicked: '', 1344 pageError: Dtgeterror(), 1345 dropDown: '', 1346 filterChoice: '', 1347 productUpdate: '0', 1348 }); 1349 } else if (gtCurPage == 'account-editprofile') { 1350 if (sessionStorage.getItem('navlink') != 'Profile') { 1351 pushDtLayer({ 1352 event: 'page_view', 1353 userId: customerNo != null ? customerNo : null, 1354 language: DtgetLanguage(), 1355 websiteCountry: DtgetCountry(), 1356 pageCategory: DtgetPageCategory(), 1357 pageSubCategory: CouponSubCategory(), 1358 navigationLinkClicked: '0', 1359 emailhash: emailID, 1360 emailHashTwo: emailID_SHA1, 1361 navigationLinkNameClicked: '', 1362 navigationLocationClicked: '', 1363 pageError: Dtgeterror(), 1364 dropDown: '', 1365 filterChoice: '', 1366 productUpdate: '0', 1367 }); 1368 } else { 1369 pushDtLayer({ 1370 event: 'page_view', 1371 userId: customerNo != null ? customerNo : null, 1372 language: DtgetLanguage(), 1373 websiteCountry: DtgetCountry(), 1374 pageCategory: DtgetPageCategory(), 1375 pageSubCategory: CouponSubCategory(), 1376 emailhash: emailID, 1377 emailHashTwo: emailID_SHA1, 1378 navigationLinkClicked: sessionStorage.getItem('navlink') ? '1' : '0', 1379 navigationLinkNameClicked: sessionStorage.getItem('navlink'), 1380 navigationLocationClicked: sessionStorage.getItem('menuloc'), 1381 pageError: Dtgeterror(), 1382 dropDown: '', 1383 filterChoice: '', 1384 productUpdate: sessionStorage.getItem('productUpdate') ? '1' : '0', 1385 }); 1386 } 1387 } else { 1388 pushDtLayer({ 1389 event: 'page_view', 1390 userId: customerNo != null ? customerNo : null, 1391 language: DtgetLanguage(), 1392 websiteCountry: DtgetCountry(), 1393 pageCategory: DtgetPageCategory(), 1394 pageSubCategory: CouponSubCategory(), 1395 emailhash: emailID, 1396 emailHashTwo: emailID_SHA1, 1397 navigationLinkClicked: sessionStorage.getItem('navlink') ? '1' : '0', 1398 navigationLinkNameClicked: sessionStorage.getItem('navlink'), 1399 navigationLocationClicked: sessionStorage.getItem('menuloc'), 1400 pageError: Dtgeterror(), 1401 dropDown: '', 1402 filterChoice: '', 1403 productUpdate: sessionStorage.getItem('productUpdate') ? '1' : '0', 1404 }); 1405 } 1406 } else if (DtgetPageCategory() == 'Product List Page') { 1407 if ( 1408 searchItems.lastclk == 'account-editprofile' || 1409 searchItems.lastclk == 'address-list' || 1410 searchItems.lastclk == 'paymentinstruments-list' || 1411 searchItems.lastclk == 'wishlist-show' || 1412 searchItems.lastclk == 'order-history' ||
1413 searchItems.lastclk == 'orderreplenishment-show' || 1414 searchItems.lastclk == 'customerservice-contactus' 1415 ) { 1416 pushDtLayer({ 1417 event: 'page_view', 1418 userId: customerNo != null ? customerNo : null, 1419 language: DtgetLanguage(), 1420 websiteCountry: DtgetCountry(), 1421 pageCategory: DtgetPageCategory(), 1422 pageSubCategory: CouponSubCategory(), 1423 emailhash: emailID, 1424 emailHashTwo: emailID_SHA1, 1425 navigationLinkClicked: getCookie('navdata') ? '1' : '0', 1426 navigationLinkNameClicked: sessionStorage.getItem('navlink') 1427 ? sessionStorage.getItem('navlink') 1428 : getCookie('navdata'), 1429 navigationLocationClicked: 'topmenu', 1430 pageError: Dtgeterror(), 1431 dropDown: '', 1432 filterChoice: '', 1433 productUpdate: sessionStorage.getItem('productUpdate') ? '1' : '0', 1434 }); 1435 } else { 1436 pushDtLayer({ 1437 event: 'page_view', 1438 userId: customerNo != null ? customerNo : null, 1439 language: DtgetLanguage(), 1440 websiteCountry: DtgetCountry(), 1441 pageCategory: DtgetPageCategory(), 1442 pageSubCategory: CouponSubCategory(), 1443 emailhash: emailID, 1444 emailHashTwo: emailID_SHA1, 1445 navigationLinkClicked: sessionStorage.getItem('navlink') ? '1' : '0', 1446 navigationLinkNameClicked: sessionStorage.getItem('navlink'), 1447 navigationLocationClicked: sessionStorage.getItem('menuloc'), 1448 pageError: Dtgeterror(), 1449 dropDown: '', 1450 filterChoice: '', 1451 productUpdate: sessionStorage.getItem('productUpdate') ? '1' : '0', 1452 }); 1453 } 1454 } else if (gtCurPage == 'customerservice-contactus') { 1455 pushDtLayer({ 1456 event: 'page_view', 1457 userId: customerNo != null ? customerNo : null, 1458 language: DtgetLanguage(), 1459 websiteCountry: DtgetCountry(), 1460 pageCategory: DtgetPageCategory(), 1461 pageSubCategory: CouponSubCategory(), 1462 navigationLinkClicked: '0', 1463 navigationLinkNameClicked: '', 1464 emailhash: emailID, 1465 emailHashTwo: emailID_SHA1, 1466 navigationLocationClicked: '', 1467 pageError: Dtgeterror(), 1468 dropDown: '', 1469 filterChoice: '', 1470 productUpdate: '0', 1471 }); 1472 } else if (gtCurPage == 'account-editprofile') { 1473 if (sessionStorage.getItem('navlink') != 'Profile') { 1474 pushDtLayer({ 1475 event: 'page_view', 1476 userId: customerNo != null ? customerNo : null, 1477 language: DtgetLanguage(), 1478 websiteCountry: DtgetCountry(), 1479 pageCategory: DtgetPageCategory(), 1480 pageSubCategory: CouponSubCategory(), 1481 navigationLinkClicked: '0', 1482 emailhash: emailID, 1483 emailHashTwo: emailID_SHA1, 1484 navigationLinkNameClicked: '', 1485 navigationLocationClicked: '', 1486 pageError: Dtgeterror(), 1487 dropDown: '', 1488 filterChoice: '', 1489 productUpdate: '0', 1490 }); 1491 } else { 1492 pushDtLayer({ 1493 event: 'page_view', 1494 userId: customerNo != null ? customerNo : null, 1495 language: DtgetLanguage(), 1496 websiteCountry: DtgetCountry(), 1497 pageCategory: DtgetPageCategory(), 1498 pageSubCategory: CouponSubCategory(), 1499 emailhash: emailID, 1500 emailHashTwo: emailID_SHA1, 1501 navigationLinkClicked: sessionStorage.getItem('navlink') ? '1' : '0', 1502 navigationLinkNameClicked: sessionStorage.getItem('navlink'), 1503 navigationLocationClicked: sessionStorage.getItem('menuloc'), 1504 pageError: Dtgeterror(), 1505 dropDown: '', 1506 filterChoice: '', 1507 productUpdate: sessionStorage.getItem('productUpdate') ? '1' : '0', 1508 }); 1509 } 1510 } else if (DtgetPageCategory() == 'Product Page') { 1511 // Retrieve the value of navlink from localStorage (if present) and then push the click event 1512 if(localStorage.navlink){ 1513 var gtmNavData = localStorage.getItem('navlink'); 1514 sessionStorage.setItem('navlink', gtmNavData); 1515 // Clear the value of navlink from localStorage 1516 localStorage.removeItem('navlink'); 1517 } 1518 pushDtLayer({ 1519 event: 'page_view', 1520 userId: customerNo != null ? customerNo : null, 1521 language: DtgetLanguage(), 1522 websiteCountry: DtgetCountry(), 1523 pageCategory: DtgetPageCategory(), 1524 pageSubCategory: CouponSubCategory(), 1525 emailhash: emailID, 1526 emailHashTwo: emailID_SHA1, 1527 navigationLinkClicked: sessionStorage.getItem('navlink') ? '1' : '0', 1528 navigationLinkNameClicked: sessionStorage.getItem('navlink'), 1529 navigationLocationClicked: sessionStorage.getItem('menuloc'), 1530 pageError: Dtgeterror(), 1531 dropDown: '', 1532 filterChoice: '', 1533 productUpdate: sessionStorage.getItem('productUpdate') ? '1' : '0', 1534 }); 1535 } else { 1536 if (typeof scriptExecuted === 'undefined') { 1537 // Set a flag to indicate that the script has been executed 1538 scriptExecuted = true; 1539 pushDtLayer({ 1540 event: 'page_view', 1541 userId: (window.User.isRegistered && customerNo != null) ? customerNo : null, 1542 language: DtgetLanguage(), 1543 websiteCountry: DtgetCountry(), 1544 pageCategory: DtgetPageCategory(), 1545 pageSubCategory: CouponSubCategory(), 1546 emailhash: emailID, 1547 emailHashTwo: emailID_SHA1, 1548 navigationLinkClicked: sessionStorage.getItem('navlink') ? '1' : '0', 1549 navigationLinkNameClicked: sessionStorage.getItem('navlink'), 1550 navigationLocationClicked: sessionStorage.getItem('menuloc'), 1551 pageError: Dtgeterror(), 1552 dropDown: '', 1553 filterChoice: '', 1554 emailHashTwo: emailID_SHA1, 1555 firstName: typeof window.customerFirstName !== 'undefined' ? window.customerFirstName : '', 1556 lastName: typeof window.customerFirstName !== 'undefined' ? window.customerLastName : '', 1557 emailAddress: typeof window.emailAddress !== 'undefined' ? window.emailAddress : '', 1558 productUpdate: sessionStorage.getItem('productUpdate') ? '1' : '0', 1559 }); 1560 } 1561 } 1562} 1563 1564sessionStorage.setItem('navlink', ''); 1565sessionStorage.setItem('menuloc', ''); 1566sessionStorage.setItem('mobilesearch', ''); 1567sessionStorage.setItem('productUpdate', ''); 1568sessionStorage.setItem('userid', userid); 1569sessionStorage.setItem('languange', DtgetLanguage()); 1570sessionStorage.setItem('webCountry', DtgetCountry());
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.