1(function($) { 2 "use strict"; 3 $(document).ready(function() { 4 var location = $("#countrycodeValue").val()+":"+$("#languagecodeValue").val() 5 +":"+$("#siteidentifierValue").val()+":"+$("#platformValue").val()+":"+ 6 $("#pagenameValue").val()+":"+$("#sitesectiononeValue").val()+":"+ 7 $("#sitesectiontwoValue").val()+":"+$("#pageidentifierValue").val(); 8 $("#tlFilters-show-filter-link").click(function(e) { 9 console.log("ShowFilters Clicked"); 10 window.dataLayer = window.dataLayer || []; 11 window.dataLayer.push({ 12 "event" : "callToAction", //e111 13 "callToAction": { 14 "location": location, //v103 15 "ctaName": "show filter", //v104 16 "ctaType": "link" //v111 17 } 18 }); 19 20 }); 21 $("#tlFilters-hide-filter-link").click(function(e) { 22 window.dataLayer.push({ 23 "event" : "callToAction", //e111 24 "callToAction": { 25 "location": location, //v103 26 "ctaName": "hide filter", //v104 27 "ctaType": "link" //v111 28 } 29 }); 30 31 }); 32 $("#tlFilters-submit").click(function(e) { 33 window.dataLayer.push({ 34 "event" : "callToAction", //e111 35 "callToAction": { 36 "location": location, //v103 37 "ctaName": "apply", //v104 38 "ctaType": "link" //v111 39 } 40 }); 41 42 }); 43 $("#iig-tl-filter-results-deSelectAll").click(function(e) { 44 window.dataLayer.push({ 45 "event" : "callToAction", //e111 46 "callToAction": { 47 "location": location, //v103 48 "ctaName": "clear all", //v104 49 "ctaType": "link" //v111 50 } 51 }); 52 53 }); 54 $("#tlFilters-deSelectAll").click(function(e) { 55 window.dataLayer.push({ 56 "event" : "callToAction", //e111 57 "callToAction": { 58 "location": location, //v103 59 "ctaName": "clear all", //v104 60 "ctaType": "link" //v111 61 } 62 }); 63 64 }); 65 }) 66 67})(jQuery); 68 69(function($) { 70 "use strict"; 71 $(document).ready(function() { 72 $(".c11n-link--secondary").click(function(e) { 73 let ctaType = $(this).attr("data-analytics"); 74 let ctaName = $(this).find('.c11n-link__content').text(); 75 let ctaLocation = $("#sitesectiontwoValue").val(); 76 if(typeof ctaType !== "undefined" && ctaType === "cta") { 77 window.dataLayer.push({ 78 "event" : "callToAction", 79 "callToAction": { 80 "location":ctaLocation, 81 "ctaName":ctaName.trim(), 82 "ctaType":"link" 83 } 84 }); 85 } 86 }); 87 }) 88})(jQuery); 89 90/** 91 * 92 * function returns page name value 93 */ 94function getPageNameValue() { 95 const countrycodeValue = document.getElementById('countrycodeValue').getAttribute('value'); 96 countrycodeValue ? countrycodeValue : ''; 97 const languagecodeValue = document.getElementById('languagecodeValue').getAttribute('value'); 98 languagecodeValue ? languagecodeValue : ''; 99 const pagetitleValue = document.getElementById('pagetitleValue').getAttribute('value'); 100 pagetitleValue ? pagetitleValue : ''; 101 const sitesectiononeValue = document.getElementById('sitesectiononeValue').getAttribute('value'); 102 sitesectiononeValue ? sitesectiononeValue : ''; 103 const sitesectiontwoValue = document.getElementById('sitesectiontwoValue').getAttribute('value'); 104 sitesectiontwoValue ? sitesectiontwoValue : ''; 105 const siteidentifierValue = document.getElementById('siteidentifierValue').getAttribute('value'); 106 siteidentifierValue ? siteidentifierValue : ''; 107 const platformValue = document.getElementById('platformValue').getAttribute('value'); 108 platformValue ? platformValue : ''; 109 const pagetemplateValue = document.getElementById('pagetemplateValue').getAttribute('value'); 110 pagetemplateValue ? pagetemplateValue : ''; 111 const subdomainValue = document.getElementById('subdomainValue').getAttribute('value'); 112 subdomainValue ? subdomainValue : ''; 113 const pagenameValue = document.getElementById('pagenameValue').getAttribute('value'); 114 pagenameValue ? pagenameValue : ''; 115 const pageidentifierValue = document.getElementById('pageidentifierValue').getAttribute('value'); 116 pageidentifierValue ? pageidentifierValue : ''; 117 return `${countrycodeValue}:${languagecodeValue}:${siteidentifierValue}:${platformValue}:${pagenameValue}:${sitesectiononeValue}:${sitesectiontwoValue}:${pageidentifierValue}`; 118} 119/** 120 * function to fire page load event for analytics 121 * 122 */ 123function pageLoadedEvent() { 124 125 if (document.querySelector('meta[name="template"]').content == 'advice-shop-site') { 126 var pagename = document.getElementById('analyticsUrl').getAttribute('value'); 127 pagename = pagename.substr(0, pagename.lastIndexOf(':')); 128 pagename += ':' + document.getElementById('sitesectiontwoValue').getAttribute('value'); 129 document.getElementById('analyticsUrl').setAttribute('value', pagename); 130 } 131 132 const psxPagenameUrl = document.getElementById('analyticsUrl'); 133 const psxPagename = psxPagenameUrl ? psxPagenameUrl.getAttribute('value') : ''; 134 const pagenameValue = document.querySelectorAll('.psx-page.page').length && psxPagenameUrl ? psxPagename : getPageNameValue(); 135 const redOakId = document.getElementById('redOakId').getAttribute('value'); 136 redOakId ? redOakId : ''; 137 const pagetitleValue = document.getElementById('pagetitleValue').getAttribute('value'); 138 pagetitleValue ? pagetitleValue : ''; 139 const sitesectiononeValue = document.getElementById('sitesectiononeValue').getAttribute('value'); 140 sitesectiononeValue ? sitesectiononeValue : ''; 141 const sitesectiontwoValue = document.getElementById('sitesectiontwoValue').getAttribute('value'); 142 sitesectiontwoValue ? sitesectiontwoValue : ''; 143 const siteidentifierValue = document.getElementById('siteidentifierValue').getAttribute('value'); 144 siteidentifierValue ? siteidentifierValue : ''; 145 const platformValue = document.getElementById('platformValue').getAttribute('value'); 146 platformValue ? platformValue : ''; 147 const pagetemplateValue = document.getElementById('pagetemplateValue').getAttribute('value'); 148 pagetemplateValue ? pagetemplateValue : ''; 149 const journeyCategoryVal = document.getElementById('journeyCategory'); 150 const journeyCategory = journeyCategoryVal ? journeyCategoryVal.getAttribute('value') : ''; 151 152 window.dataLayer = window.dataLayer || []; 153 window.dataLayer.push({ 154 event: 'pageLoaded', 155 page: { 156 pageName: pagenameValue, //c18, v18 157 pageTitle: pagetitleValue, //c30 158 siteSection1: sitesectiononeValue, //c38 159 siteSection2: sitesectiontwoValue, //c39 160 is404: false, //boolean true/false value 161 DLVersion: '1.0.0', //v42 162 platform: platformValue, 163 siteIdentifier: siteidentifierValue, 164 pageTemplate: pagetemplateValue, //v157 165 pageRedOakId: redOakId, 166 journeyCategory: journeyCategory 167 } 168 }); 169} 170 171function updatePageContentArticleAttributes() { 172 const templateName = document.querySelector("meta[name='template']").getAttribute('content'); 173 if (templateName == 'page-content') { 174 const articleContentKingdomProfile = document.querySelector("meta[name='content_kingdom']").getAttribute('content'); 175 const articleClassProfile = document.querySelector("meta[name='class']").getAttribute('content'); 176 const articleThemeProfile = document.querySelector("meta[name='theme']").getAttribute('content'); 177 const articleTopicProfile = document.querySelector("meta[name='topic']").getAttribute('content'); 178 const articleSubTopicProfile = document.querySelector("meta[name='sub_topic']").getAttribute('content'); 179 const articleTopicSecondaryProfile = document.querySelector("meta[name='topic_secondary']").getAttribute('content'); 180 const requestedOrgProfile = document.querySelector("meta[name='requested_org']").getAttribute('content'); 181 const messageSmeProfile = document.querySelector("meta[name='message_sme']").getAttribute('content'); 182 const podNameProfile = document.querySelector("meta[name='pod_n
182ame']").getAttribute('content'); 183 const articleLaunchDateProfile = document.querySelector("meta[name='article_launch_date']").getAttribute('content'); 184 const articleRoleProfile = document.querySelector("meta[name='audience_role']").getAttribute('content'); 185 const articleInitiativeProfile = document.querySelector("meta[name='initiative']").getAttribute('content'); 186 const articleVerticlesProfile = document.querySelector("meta[name='verticles']").getAttribute('content'); 187 const articleIdProfile = document.querySelector("meta[name='article_unique_id']").getAttribute('content'); 188 189 window.dataLayer = window.dataLayer || []; 190 if (window.dataLayer) { 191 const dateProfile = articleLaunchDateProfile ? `${articleLaunchDateProfile}` : ''; 192 const categoryProfile = [articleContentKingdomProfile,articleClassProfile,articleThemeProfile,articleTopicProfile,articleSubTopicProfile,articleTopicSecondaryProfile,podNameProfile].map(v => v ? v : 'null').join(':'); 193 const subCategoryProfile = [requestedOrgProfile, messageSmeProfile].map(v => v ? v : 'null').join(':'); 194 const targetingProfile = [articleRoleProfile,articleInitiativeProfile,articleVerticlesProfile].map(v => v ? v : 'null').join(':'); 195 window.dataLayer.push({ 196 event: 'articleAttributes', //e279 197 article: { 198 articleLifecycleDate: dateProfile, //v164 199 articleCategory: categoryProfile, //v159 200 articleSubCategory: subCategoryProfile, //v160 201 articleId: articleIdProfile, 202 articleTargeting: targetingProfile, //v67 203 }, 204 }); 205 } 206 } 207}/** 208 * function to check whether the page is an article or not and datalayer push 209 * 210 */ 211function updateArticleAttributes() { 212 if ($('.container.article').length > 0 || $('.psxarticlepage.page').length > 0 || $('.campaignarticlepage.page').length > 0) { 213 214 const articleContentKingdomEle = document.getElementById('articleContentKingdom'); 215 const articleClassEle = document.getElementById('articleClass'); 216 const articleThemeEle = document.getElementById('articleTheme'); 217 const articleDateEle = document.getElementById('articleDate'); 218 const articleexpirationDateEle = document.getElementById('expirationDate'); 219 const articleIdEle = document.getElementById('articleId'); 220 const articleTopicEle = document.getElementById('articleTopic'); 221 const articleSubTopicEle = document.getElementById('articleSubTopic'); 222 const articleTopicSecondaryEle = document.getElementById('articleTopicSecondary'); 223 const requestedOrgEle = document.getElementById('requestedOrg'); 224 const messageSmeEle = document.getElementById('messageSme'); 225 const podNameEle = document.getElementById('podName'); 226 const articleRelationshipEle = document.getElementById('articleRelationship'); 227 const articleRoleEle = document.getElementById('articleRole'); 228 const articleInitiativeEle = document.getElementById('articleInitiative'); 229 const articleVerticlesEle = document.getElementById('articleVerticles'); 230 const articleTargetPopulationEle = document.getElementById('articleTargetPopulation');
231 const articleThumbnailUrlEle = document.getElementById('articleThumbnailUrl'); 232 const psxarticleCategoryEle = document.getElementById('articleCategory'); 233 let articleContentKingdom = ''; 234 let articleClass = ''; 235 let articleTheme = ''; 236 let articleDate = ''; 237 let expirationDate = ''; 238 let articleIdValue = ''; 239 let articleTopic = ''; 240 let articleSubTopic = ''; 241 let articleTopicSecondary = ''; 242 let requestedOrg = ''; 243 let podName = ''; 244 let messageSme = ''; 245 let articleRelationship = ''; 246 let articleRole = ''; 247 let articleInitiative = ''; 248 let articleVerticles = ''; 249 let articleTargetPopulation = ''; 250 let articleThumbnailUrl = ''; 251 let articleThumbnailFullUrl = ''; 252 let psxarticleCategory = ''; 253 if (articleContentKingdomEle) { 254 articleContentKingdom = articleContentKingdomEle.getAttribute('value'); 255 articleContentKingdom ? articleContentKingdom : ''; 256 } 257 if (articleClassEle) { 258 articleClass = articleClassEle.getAttribute('value'); 259 articleClass ? articleClass : ''; 260 } 261 if (articleThemeEle) { 262 articleTheme = articleThemeEle.getAttribute('value'); 263 articleTheme ? articleTheme : ''; 264 } 265 if (articleDateEle) { 266 articleDate = articleDateEle.getAttribute('value'); 267 articleDate ? articleDate : ''; 268 } 269 if (articleexpirationDateEle) { 270 expirationDate = articleexpirationDateEle.getAttribute('value'); 271 expirationDate ? expirationDate : ''; 272 } 273 if (articleIdEle) { 274 articleIdValue = articleIdEle.getAttribute('value'); 275 articleIdValue ? articleIdValue : ''; 276 } 277 if (articleTopicEle) { 278 articleTopic = articleTopicEle.getAttribute('value'); 279 articleTopic ? articleTopic : ''; 280 } 281 if (articleSubTopicEle) { 282 articleSubTopic = articleSubTopicEle.getAttribute('value'); 283 articleSubTopic ? articleSubTopic : ''; 284 } 285 if (articleTopicSecondaryEle) { 286 articleTopicSecondary = articleTopicSecondaryEle.getAttribute('value'); 287 articleTopicSecondary ? articleTopicSecondary : ''; 288 } 289 if (podNameEle) { 290 podName = podNameEle.getAttribute('value'); 291 podName ? podName : ''; 292 } 293 if (requestedOrgEle) { 294 requestedOrg = requestedOrgEle.getAttribute('value'); 295 requestedOrg ? requestedOrg : ''; 296 } 297 if (messageSmeEle) { 298 messageSme = messageSmeEle.getAttribute('value'); 299 messageSme ? messageSme : ''; 300 } 301 if (articleInitiativeEle) { 302 articleInitiative = articleInitiativeEle.getAttribute('value'); 303 articleInitiative ? articleInitiative : ''; 304 } 305 if (articleRelationshipEle) { 306 articleRelationship = articleRelationshipEle.getAttribute('value'); 307 articleRelationship ? articleRelationship : ''; 308 } 309 if (articleRoleEle) { 310 articleRole = articleRoleEle.getAttribute('value'); 311 articleRole ? articleRole : ''; 312 } 313 if (articleVerticlesEle) { 314 articleVerticles = articleVerticlesEle.getAttribute('value'); 315 articleVerticles ? articleVerticles : ''; 316 } 317 if (articleTargetPopulationEle) { 318 articleTargetPopulation = articleTargetPopulationEle.getAttribute('value'); 319 articleTargetPopulation ? articleTargetPopulation : ''; 320 }
321 if (articleThumbnailUrlEle) { 322 articleThumbnailUrl = articleThumbnailUrlEle.getAttribute('value'); 323 articleThumbnailFullUrl = `${window.location.origin}${articleThumbnailUrl}`; 324 articleThumbnailFullUrl ? articleThumbnailFullUrl : ''; 325 } 326 if (psxarticleCategoryEle) { 327 psxarticleCategory = psxarticleCategoryEle.getAttribute('value'); 328 psxarticleCategory ? psxarticleCategory : ''; 329 } 330 if (window.dataLayer) { 331 const articleLifecycleDate = articleDate && expirationDate ? `${articleDate}:${expirationDate}` : ''; 332 const articleCategoryUrl = [articleContentKingdom,articleClass,articleTheme,articleTopic,articleSubTopic,articleTopicSecondary,podName].map(v => v ? v : 'null').join(':'); 333 const articleCategory = document.querySelectorAll('.psx-page.page').length && psxarticleCategoryEle ? psxarticleCategory : articleCategoryUrl; 334 const articleSubCategory = [requestedOrg, messageSme].map(v => v ? v : 'null').join(':'); 335 const articleTargeting = [articleRelationship,articleRole,articleTargetPopulation,articleInitiative,articleVerticles].map(v => v ? v : 'null').join(':'); 336 window.dataLayer.push({ 337 event: 'articleAttributes', //e279 338 article: { 339 articleLifecycleDate: articleLifecycleDate, //v164 340 articleCategory: articleCategory, //v159 341 articleSubCategory: articleSubCategory, //v160 342 articleId: articleIdValue, 343 articleTargeting: articleTargeting, //v67
344 articleThumbnailUrl: articleThumbnailFullUrl, 345 }, 346 }); 347 } 348 } 349} 350/** 351 * function to fire sub page view event for analytics 352 * 353 */ 354function subPageViewed(subPageID, spaClicked) { 355 window.dataLayer = window.dataLayer || []; 356 window.dataLayer.push({ 357 event: 'subPageViewed', 358 subPage: { 359 subPageID: subPageID, 360 spClicked: spaClicked, 361 }, 362 }); 363} 364/** 365 * function to bind subpageview event 366 * 367 */ 368function bindSubPageView(eles) { 369 const firstId = eles[0].innerText; 370 /*on the page load by deafult the first tab data layer should be pushed */ 371 subPageViewed(firstId, false); 372 eles.forEach((ele) => { 373 ele.addEventListener('click', () => { 374 const _id = ele.innerText; 375 subPageViewed(_id, true); 376 }); 377 }); 378} 379/** 380 * function to update datalayer with subpage on tab and navigation click 381 */ 382function tabAnalytics() { 383 const tabListAll = document.querySelectorAll('.cmp-tabs__wrapper .cmp-tabs__tablist li'); 384 if (tabListAll && tabListAll.length) { 385 bindSubPageView(tabListAll); 386 } 387 const iigTabListAll = document.querySelectorAll('.iig-tabs .cmp-tabs__tablist li'); 388 if (iigTabListAll && iigTabListAll.length) { 389 bindSubPageView(iigTabListAll); 390 } 391 const navListAll = document.querySelectorAll('.cmp-inPagenavigation__lists li'); 392 if (navListAll && navListAll.length) { 393 bindSubPageView(navListAll); 394 } 395 const tabListAllForMI = document.querySelectorAll('.more-insights-tabs ul li'); 396 if (tabListAllForMI && tabListAllForMI.length) { 397 bindSubPageView(tabListAllForMI); 398 } 399 const event = new CustomEvent('TDFGlidePathUpdate', {}); 400 document.dispatchEvent(event); 401} 402/** 403 * function to fire page load completed event for analytics 404 * 405 */ 406function pageLoadCompleted() { 407 if (window.dataLayer) { 408 window.dataLayer.push({ 409 event: 'pageLoadCompleted', 410 }); 411 } 412} 413/** 414 * function to fire event detection on event template 415 */ 416function eventDetection() { 417 if ($('.eventspage.page').length > 0) { 418 const eventTypeEle = document.getElementById('eventType'); 419 const eventDateEle = document.getElementById('eventDate'); 420 let eventDate = ''; 421 let eventType = ''; 422 if (eventTypeEle) { 423 eventType = eventTypeEle.getAttribute('value'); 424 eventType ? eventType : ''; 425 } 426 if (eventDateEle) { 427 eventDate = eventDateEle.getAttribute('value'); 428 eventDate ? eventDate : ''; 429 } 430 const eventCategory = eventType && eventDate ? `${eventType}:${eventDate}` : ''; 431 if (window.dataLayer) { 432 window.dataLayer.push({ 433 event: 'eventAttributes', //e111 434 eventInfo: { 435 eventCategory: eventCategory 436 } 437 }); 438 } 439 } 440} 441/* 442 * Handles user identification and pushes login details to dataLayer 443 */ 444function userIdentification(respValue) { 445 tabAnalytics(); 446 updateArticleAttributes(); 447 updatePageContentArticleAttributes(); 448 eventDetection(); 449 pageLoadCompleted(); 450 if (window.dataLayer) { 451 window.dataLayer.push({ 452 event: 'userDetected', 453 user: { 454 sPOID: respValue ? $.trim(respValue.sPOID) : '', //v1 455 crewsPOID: respValue ? $.trim(respValue.sPOID) : '', //c7, v7 456 loginStatus: 'Logged In', //v8 457 vaporflyUserID: '', //v240 This field is only applicable for the vaporfly site 458 loginIdType:'1', //v62 459 }, 460 }); 461 } 462} 463 464/** 465 * function to fire user detected event for analytics 466 * 467 */ 468function userDetected(respValue) { 469 setTimeout(function() { 470 if (respValue && typeof respValue.sPOID !== 'undefined') { 471 userIdentification(respValue); 472 } else { 473 if (window.dataLayer) { 474 window.dataLayer.push({ 475 event: 'userDetected', 476 user: { 477 sPOID: '', // v1 478 loginStatus: 'Logged Out', // v8 479 vaporflyUserID: '', // v240 This field is only applicable for the vaporfly site 480 loginIdType: '', // v62 481 }, 482 }); 483 tabAnalytics(); 484 updateArticleAttributes(); 485 updatePageContentArticleAttributes(); 486 eventDetection(); 487 pageLoadCompleted(); 488 } 489 } 490 }, 1000); 491} 492 493/** 494 * function to fire callToAction event 495 */ 496function callToAction(event, buttonType) { 497 const isAdvicePage = document.querySelector('.psx-page.page.basicpage'); 498 const btnElement = event.currentTarget; 499 let btnLocation = ''; 500 if (btnElement) { 501 btnLocation = btnElement.getAttribute('data-location'); 502 } 503 const buttonText = event.target.innerText; 504 const sitesectiontwoValue = document.getElementById('sitesectiontwoValue').getAttribute('value'); 505 sitesectiontwoValue ? sitesectiontwoValue : ''; 506 window.dataLayer = window.dataLayer || []; 507 window.dataLayer.push({ 508 event: 'callToAction', //e111 509 callToAction: { 510 location: isAdvicePage ? sitesectiontwoValue.toLowerCase() : getPageNameValue(), //v103 511 ctaName: btnLocation ? buttonText.toLowerCase() + ' | ' + btnLocation.toLowerCase() : buttonText.toLowerCase(), //v104 512 ctaType: buttonType.toLowerCase(), //v111 513 }, 514 }); 515} 516 517/** 518 * function to fire callToAction event 519 */ 520function callToActionModel(buttonText, buttonType, location) { 521 window.dataLayer = window.dataLayer || []; 522 window.dataLayer.push({ 523 event: 'callToAction', //e111 524 callToAction: { 525 location: location, //v103 526 ctaName: buttonText, //v104 527 ctaType: buttonType, //v111 528 }, 529 }); 530} 531function trackNavigatipnPopup(linkElement) 532{ 533 const modalId = linkElement.getAttribute('href').replace('#', ''); 534 let modalTitle = $('#' + modalId).find('.vg-title').children().text().replace(/[^a-zA-Z0-9 :\-|]/g, ''); 535 modalTitle = typeof modalTitle != 'undefined' ? modalTitle.trim() : event.target.innerText; 536 const siteSectionEle = document.getElementById('sitesectiontwoValue'); 537 let siteSectionValue = ''; 538 if (siteSectionEle) { 539 siteSectionValue = siteSectionEle.getAttribute('value'); 540 siteSectionValue ? siteSectionValue : ''; 541 } 542 let linkName = siteSectionValue + ':' + event.target.innerText; 543 if (modalTitle !== '') 544 { 545 linkName = siteSectionValue + ':' + modalTitle + '|' + event.target.innerText; 546 } 547 window.dataLayer.push({ 548 event: 'navigationPopup', 549 navigationPopup: { 550 linkName: linkName, 551 }, 552 }); 553} 554/** 555 * function to fire request for info event for analytics 556 * 557 */ 558function captureIIGButtonClick(event) { 559 const btnElement = event.currentTarget; 560 let btnTrackValue = ''; 561 if (btnElement) { 562 btnTrackValue = btnElement.getAttribute('button-tracking-value'); 563 } 564 window.dataLayer = window.dataLayer || []; 565 if (btnTrackValue == 'requestforInfo') { 566 window.dataLayer.push({ 567 event: 'requestForInfoAlways', 568 requestForInfo: { 569 requestForInfo: event.target.innerText, 570 }, 571 }); 572 window.dataLayer.push({ 573 event: 'requestForInfoOnce', 574 requestForInfo: { 575 requestForInfo: event.target.innerText, 576 }, 577 }); 578 } 579 if (btnTrackValue == 'onSiteLink') { 580 const siteSectionEle = document.getElementById('sitesectiontwoValue'); 581 let siteSectionValue = ''; 582 if (siteSectionEle) { 583 siteSectionValue = siteSectionEle.getAttribute('value'); 584 siteSectionValue ? siteSectionValue : ''; 585 } 586 window.dataLayer.push({ 587 event: 'onSiteLinkClick', 588 onSiteLink: { 589 linkName: siteSectionValue + '|' + event.target.innerText, 590 }, 591 }); 592 } 593 if (btnTrackValue == 'cta') { 594 const parentEl = btnElement.closest('.iig-button'); 595 const parentElCore = btnElement.closest('.c11n-button'); 596 const parentClickLinkEl = btnElement.closest('.click-link'); 597 let buttonType = ''; 598 if (parentEl && parentEl.classList.contains('iig-button-custom-primary')) { 599 buttonType = 'Primary button'; 600 } 601 else if (parentEl && parentEl.classList.contains('iig-button-custom-secondary')) { 602 buttonType = 'Secondary button'; 603 } 604 else if (parentEl && parentEl.classList.contains('iig-button-read-more')) { 605 buttonType = 'Read more'; 606 } 607 else if (parentEl && parentEl.classList.contains('iig-button-connect')) { 608 buttonType = 'connect'; 609 } 610 else if ((parentElCore && parentElCore.classList.contains('c11n-button--primary')) || (parentClickLinkEl && parentClickLinkEl.classList.contains('c11n-button--primary'))) { 611 buttonType = 'Primary button Black'; 612 } 613 else if ((parentElCore && parentElCore.classList.contains('c11n-button--primary-red')) || (parentClickLinkEl && parentClickLinkEl.classList.contains('c11n-button--primary-red'))) { 614 buttonType = 'Primary button Red'; 615 } 616 else if ((parentElCore && parentElCore.classList.contains('c11n-button--secondary'))||(parentClickLinkEl && parentClickLinkEl.classList.contains('c11n-button--secondary'))) { 617 buttonType = 'Secondary button'; 618 } 619 else if (parentClickLinkEl && parentClickLinkEl.classList.contains('c11n-link-primary-independent')) { 620 buttonType = 'Primary Button'; 621 } 622 else if (parentClickLinkEl && parentClickLinkEl.classList.contains('c11n-link-secondary-independent')) { 623 buttonType = 'Secondary Button'; 624 } 625 else if (parentClickLinkEl && parentClickLinkEl.classList.contains('c11n-link-definition')) { 626 buttonType = 'Glossary Button'; 627 } 628 else if (parentClickLinkEl && parentClickLinkEl.classList.contains('c11n-button--trailing-icon-primary')) { 629 buttonType = 'Primary button Black'; 630 } 631 else if (parentClickLinkEl && parentClickLinkEl.classList.contains('c11n-button--leading-icon-primary')) { 632 buttonType = 'Primary button Black'; 633 } 634 callToAction(event, buttonType); 635 } 636 if (btnTrackValue == 'contentDownloaded') { 637 const siteSectionEle = document.getElementById('sitesectiontwoValue'); 638 let siteSectionValue = ''; 639 if (siteSectionEle) { 640 siteSectionValue = siteSectionEle.getAttribute('value'); 641 siteSectionValue ? siteSectionValue : ''; 642 } 643 const btnElement = event.currentTarget;
644 const fileLocation = btnElement.getAttribute('href') ? btnElement.getAttribute('href') : ''; 645 const fileFormat = fileLocation.substring(fileLocation.lastIndexOf('.') + 1) ? fileLocation.substring(fileLocation.lastIndexOf('.') + 1) : ''; 646 var fileTitle = ''; 647 if (btnElement.classList.contains('c11n-button')) 648 { 649 fileTitle = btnElement.querySelector('.c11n-button__label') ? btnElement.querySelector('.c11n-button__label').innerHTML : ''; 650 } 651 else { 652 fileTitle = btnElement.querySelector('.c11n-link__content') ? btnElement.querySelector('.c11n-link__content').innerText : ''; 653 } 654 window.dataLayer.push({ 655 event: 'contentDownloaded', //e24 656 linkInfo: { 657 fileName: siteSectionValue + ':' + fileFormat + ':' + fileTitle.trim(), //v70 658 fileLocation: fileLocation //v63 659 } 660 }); 661 } 662 if (btnTrackValue == 'navigationPopup') { 663 trackNavigatipnPopup(btnElement); 664 } 665} 666/** 667 * function to pass Link value to data layer event 668 * 669 */ 670function captureLinkClick(event) { 671 const linkElement = event.currentTarget; 672 let linkTrackValue = ''; 673 let linkText = ''; 674 if (linkElement) { 675 linkTrackValue = linkElement.getAttribute('data-attr-analytics'); 676 } 677 const siteSectionEle = document.getElementById('sitesectiontwoValue'); 678 let siteSectionValue = ''; 679 if (siteSectionEle) { 680 siteSectionValue = siteSectionEle.getAttribute('value'); 681 siteSectionValue ? siteSectionValue : ''; 682 } 683 if (linkElement.innerHTML.includes('<span')) 684 { 685 const linkArray = linkElement.innerHTML.split('<span'); 686 linkText = linkArray[0].replace(/<[^>]*>/g, ''); 687 } 688 else { 689 linkText = linkElement.innerText; 690 } 691 // RTE is rendering only & as & so converting to & before escaping 692 linkText = linkText.replace(/&/g, '&'); 693 linkText = linkText.replace(/[^a-zA-Z0-9 :\-|]/g, ''); 694 if (linkTrackValue == 'onSiteLink') { 695 window.dataLayer.push({ 696 event: 'onSiteLinkClick', 697 onSiteLink: { 698 linkName: siteSectionValue + '|' + linkText, 699 }, 700 }); 701 } 702 if (linkTrackValue == 'contentDownloaded') { 703 const btnElement = event.currentTarget;
704 const fileLocation = btnElement.getAttribute('href') ? btnElement.getAttribute('href') : ''; 705 const fileFormat = fileLocation.substring(fileLocation.lastIndexOf('.') + 1) ? fileLocation.substring(fileLocation.lastIndexOf('.') + 1) : ''; 706 window.dataLayer.push({ 707 event: 'contentDownloaded', //e24 708 linkInfo: { 709 fileName: siteSectionValue + ':' + fileFormat + ':' + linkText, //v70 710 fileLocation: fileLocation //v63 711 } 712 }); 713 } 714 if (linkTrackValue == 'navigationPopup') { 715 trackNavigatipnPopup(linkElement); 716 } 717} 718/** 719 * function to pass button/Link value to data layer event 720 * 721 */ 722function clickInfoAnalytics() { 723 const infoLinks = document.querySelectorAll('.click-info .click-link'); 724 for (let i = 0; i < infoLinks.length; i++) { 725 var infoLink = infoLinks[i]; 726 infoLink.addEventListener('click', function (event) { 727 captureIIGButtonClick(event); 728 event.stopPropagation(); 729 }); 730 } 731} 732/** 733 * function to pass button/Link value to data layer event 734 * 735 */ 736function clickRTELinkAnalytics() { 737 const textLinks = document.querySelectorAll('.c11n-link'); 738 for (let i = 0; i < textLinks.length; i++) { 739 var infoLinks1 = textLinks[i]; 740 infoLinks1.addEventListener('click', function (event) { 741 captureLinkClick(event); 742 event.stopPropagation(); 743 }); 744 } 745} 746/** 747 * function to pass IIG Text/Link value to data layer event 748 * 749 */ 750function clickIIGTextLinkAnalytics() { 751 const textLinks = document.querySelectorAll('.iig-text a'); 752 for (let i = 0; i < textLinks.length; i++) { 753 var infoLinks1 = textLinks[i]; 754 infoLinks1.addEventListener('click', function (event) { 755 captureLinkClick(event); 756 event.stopPropagation(); 757 }); 758 } 759} 760/** 761 * function to pass Login link value to data layer event 762 * 763 */ 764function clickLoginAnalytics(loginLink) { 765 let linkText = ''; 766 if (loginLink != null && typeof loginLink != 'undefined') 767 { 768 loginLink.addEventListener('click', function (event) { 769 if (loginLink.innerHTML.includes('<span')) 770 { 771 const linkArray = loginLink.innerHTML.split('<span'); 772 linkText = linkArray[0]; 773 } 774 window.dataLayer.push({ 775 event: 'onSiteLinkClick', 776 onSiteLink: { 777 linkName: 'global header' + '|' + linkText, 778 }, 779 }); 780 }); 781 } 782} 783function clickEkitLoginAnalytics() { 784 const loginLink = document.querySelector('.cmp-employer-header__top-login'); 785 clickLoginAnalytics(loginLink); 786} 787function clickAdviceLoginAnalytics() { 788 const loginLink = document.querySelector('.cmp-advice-header__top-login'); 789 clickLoginAnalytics(loginLink); 790} 791/** 792 * function to fire request for info event for analytics for fspot 793 * 794 */ 795function captureFspotClick(event) { 796 const btnElement = event.currentTarget; 797 let btnTrackValue = ''; 798 let linkText = ''; 799 if (btnElement) { 800 btnTrackValue = btnElement.getAttribute('button-tracking-value'); 801 } 802 if (btnTrackValue == 'onSiteLink') { 803 const siteSectionEle = document.getElementById('sitesectiontwoValue'); 804 let siteSectionValue = ''; 805 if (siteSectionEle) { 806 siteSectionValue = siteSectionEle.getAttribute('value'); 807 siteSectionValue ? siteSectionValue : ''; 808 }
809 linkText = btnElement.querySelector('.fspot-wrapper__item-wrap--desc-links .link').innerText; 810 window.dataLayer.push({ 811 event: 'onSiteLinkClick', 812 onSiteLink: { 813 linkName: siteSectionValue + '|' + linkText, 814 }, 815 }); 816 } 817 if (btnTrackValue == 'contentDownloaded') { 818 const siteSectionEle = document.getElementById('sitesectiontwoValue'); 819 let siteSectionValue = ''; 820 if (siteSectionEle) { 821 siteSectionValue = siteSectionEle.getAttribute('value'); 822 siteSectionValue ? siteSectionValue : ''; 823 } 824 const btnElement = event.currentTarget; 825 const fileLocation = btnElement.getAttribute('href') ? btnElement.getAttribute('href') : ''; 826 const fileFormat = fileLocation.substring(fileLocation.lastIndexOf('.') + 1) ? fileLocation.substring(fileLocation.lastIndexOf('.') + 1) : ''; 827 const fileTitle = btnElement.querySelector('.fspot-wrapper__item-wrap--desc-title') ? btnElement.querySelector('.fspot-wrapper__item-wrap--desc-title').innerHTML : ''; 828 window.dataLayer.push({ 829 event: 'contentDownloaded', //e24 830 linkInfo: { 831 fileName: siteSectionValue + ':' + fileFormat + ':' + fileTitle, //v70 832 fileLocation: fileLocation //v63 833 } 834 }); 835 } 836} 837/** 838 * function to pass button/Link value to data layer event 839 * 840 */ 841function clickFspotAnalytics() { 842 const infoLinks = document.querySelectorAll('.fspot-wrapper .fspot-wrapper__item'); 843 for (let i = 0; i < infoLinks.length; i++) { 844 var infoLink = infoLinks[i]; 845 infoLink.addEventListener('click', function (event) { 846 captureFspotClick(event); 847 event.stopPropagation(); 848 }); 849 } 850} 851/** 852 * api call to get the user detected data 853 */ 854function userDetectedApi(userStatus) { 855 const userDetectedUrl = window.location.origin + '/fd2kong/oauth/users/SPOID'; 856 try { 857 if (window.Granite && window.Granite.author) { return; } 858 if(userStatus) { 859 axios 860 .get(userDetectedUrl) 861 .then(function (response) { 862 if (response.data) { 863 const respValue = response.data; 864 userDetected(respValue); 865 } 866 }) 867 .catch(function (error) { 868 userDetected(); 869 }); 870 } else { 871 userDetected(); 872 } 873 } catch (error) { 874 console.error('Unable to fetch user detected data'); 875 } 876} 877/** 878 * function to fire reset the data layer for analytics 879 * 880 */ 881function resetDataLayer() { 882 window.dataLayer.length = 0; 883} 884 885document.addEventListener('analyticsDataLayerUpdate', (event) => { 886 pageLoadedEvent(); 887 userDetectedApi(event.detail.isLoggedIn); 888}); 889 890/** 891 * function to pass button value to data layer event 892 * 893 */ 894function buttonInfoAnalytics() { 895 const iigButtons = document.querySelectorAll('.iig-button .cmp-button'); 896 for (let i = 0; i < iigButtons.length; i++) { 897 var iigButton = iigButtons[i]; 898 iigButton.addEventListener('click', function (event) { 899 captureIIGButtonClick(event); 900 }); 901 } 902} 903 904function insightsToggleButtonAnalytics(cssSelector) { 905 const gridBtnEl = document.querySelector( 906 `${cssSelector} button${cssSelector}__grid-btn` 907 ); 908 const listBtnEl = document.querySelector( 909 `${cssSelector} button${cssSelector}__list-btn` 910 ); 911 gridBtnEl && 912 gridBtnEl.addEventListener('click', () => { 913 callToAction('Grid', 'Toggle Icon'); 914 }); 915 listBtnEl && 916 listBtnEl.addEventListener('click', () => { 917 callToAction('List', 'Toggle Icon'); 918 }); 919} 920 921/** 922 * function to fire callToAction event on click of Attestation Modal buttons 923 */ 924function attestationModalButtonAnalytics() { 925 const attestationModalAcceptBtn = document.getElementById( 926 'vg-modal-accept-btn' 927 ); 928 const attestationModalDeclineBtn = document.getElementById( 929 'vg-modal-decline-btn' 930 ); 931 932 attestationModalAcceptBtn && 933 attestationModalAcceptBtn.addEventListener('click', function () { 934 callToActionModel('Accept', 'Button', 'attestation model'); 935 }); 936 attestationModalDeclineBtn && 937 attestationModalDeclineBtn.addEventListener('click', function () { 938 callToActionModel('Decline', 'Link', 'attestation model'); 939 }); 940} 941/**
942 * Function to add callToAction event to the dataLayer object for Filter Horizontal Component 943 * Adds event when selected filter or clicked on show more. 944 * @param {*} name string name of the cta button/filter. 945 * @param {*} type string type of the cta button/filter. 946 */ 947function filterHorizontalAnalytics(theme, name, type) { 948 window.dataLayer = window.dataLayer || []; 949 const siteSection2 = document.getElementById('sitesectiontwoValue'); 950 window.dataLayer.push({ 951 event: 'callToAction', //e111 952 callToAction: { 953 ctaName: theme && theme.split('/').pop().replaceAll('-', ' ') + ':' + name.toLowerCase(), //v104 954 location: (siteSection2 && siteSection2.getAttribute('value')) || '', //v103 955 ctaType: type, //v111 956 }, 957 }); 958} 959 960/** 961 * function to fire request for info event for analytics 962 * 963 */ 964 965function analyticsFooterLinkClick(event) { 966 const anchorElement = event.currentTarget; 967 let anchorTrackValue = ''; 968 let linkText = ''; 969 let headerTextValue = ''; 970 let headerText = ''; 971 let analyticsText = ''; 972 if (anchorElement) { 973 anchorTrackValue = anchorElement.getAttribute('button-tracking-value'); 974 } 975 976 977 if (anchorTrackValue == 'onSiteLink') { 978 headerText = anchorElement.parentElement.parentElement.parentElement; 979 headerTextValue = headerText.querySelector('.psx-footer-links__wrap .psx-footer-links--title-wrap a').innerText; 980 linkText = anchorElement.innerText; 981 if (anchorElement.hasAttribute('data-analyticstext')) { 982 analyticsText = anchorElement.getAttribute('data-analyticstext'); 983 } 984 window.dataLayer = window.dataLayer || []; 985 window.dataLayer.push({ 986 event: 'onSiteLinkClick', //e264 987 onSiteLink: { 988 linkName: 'advice footer' + '| ' + headerTextValue + ':' + analyticsText, //v247 989 }, 990 }); 991 } 992} 993 994 995/** 996 function to press anchor tag text to data layer 997 */ 998function clickAdvisorFooterAnalytics() { 999 const infoLinks = document.querySelectorAll('.advice-footerlinks .psx-footer-links__redirect li a'); 1000 for (let i = 0; i < infoLinks.length; i++) { 1001 infoLinks[i].addEventListener('click', function (event) { 1002 analyticsFooterLinkClick(event); 1003 event.stopPropagation(); 1004 }); 1005 } 1006} 1007 1008/** 1009 * Function to add callToAction event to the dataLayer object for Carousel Component 1010 * when user clicked on numbers or on arrows . 1011 */ 1012function captureIIGCarouselClick(ctaTitle,type) { 1013 const siteSection2 = document.getElementById('sitesectiontwoValue'); 1014 window.dataLayer = window.dataLayer || []; 1015 window.dataLayer.push({ 1016 event: 'callToAction', //e111 1017 callToAction: { 1018 ctaName: ctaTitle, //v104 1019 location: (siteSection2 && siteSection2.getAttribute('value')) || '', //v103 1020 ctaType: type, //v111 1021 }, 1022 }); 1023} 1024 1025function carouselAnalytics() { 1026 const selectorItems = ['.carouselimageandtext .owl-dots button', '.carouselimageandtext .owl-nav button']; 1027 const type='carousel'; 1028 selectorItems.forEach((selector) => { 1029 document.querySelectorAll(selector).forEach(ele => { 1030 ele.addEventListener('click', function (event) { 1031 setTimeout(() => { 1032 const selectedItemText = document.querySelector('.carouselimageandtext .owl-item.active ' + 1033 '.cmp-psx-carousalimagetext__content-title-h2').textContent; 1034 captureIIGCarouselClick(selectedItemText, type); 1035 }, 100); 1036 }); 1037 }); 1038 }); 1039} 1040function trackGenericCarouselAnalytics() { 1041 const selectorItems = ['.generic-carousel .owl-dots button', '.generic-carousel .owl-nav button']; 1042 const type='carousel'; 1043 selectorItems.forEach((selector) => { 1044 document.querySelectorAll(selector).forEach(ele => { 1045 ele.addEventListener('click', function (event) { 1046 setTimeout(() => { 1047 const selectedItemText = document.querySelector('.generic-carousel .owl-item.active ' + 1048 '.psx-quotations__title').textContent; 1049 captureIIGCarouselClick(selectedItemText, type); 1050 }, 100); 1051 }); 1052 }); 1053 }); 1054} 1055function vgAccordion () { 1056 var accordionButton = $('.vg-accordion .cmp-accordion__button'); 1057 $(accordionButton).click(function () { 1058 // Used to track accordion clicks 1059 var tab = accordionButton.closest('.cmp-tabs__tabpanel--active'); 1060 var sectionTitle = tab.children('.iig-tab-title').text(); 1061 sectionTitle = sectionTitle.replace(/[^\w\s]/gi, ''); 1062 var accordionName = $.trim($(this).find('.cmp-accordion__title').html()); 1063 accordionName = accordionName.replace(/[^\w\s]/gi, ''); 1064 window.dataLayer.push({
1065 event: 'accordionClick', 1066 accordion: { 1067 accordionName: sectionTitle + ':' + accordionName, 1068 }, 1069 }); 1070 }); 1071} 1072function dataWrapperEvents () { 1073 const highlightTriggered = {}; 1074 window.dataLayer = window.dataLayer || []; 1075 datawrapper.on('highlight.set', ({chartId, data}) => { 1076 if (chartId == 'W7j6x') { 1077 if (!highlightTriggered[chartId]) { 1078 highlightTriggered[chartId] = true; 1079 window.dataLayer.push({ 1080 event: 'toolUsed', 1081 tool: { 1082 toolName: chartId, //v93 1083 toolCategory: 'dataWrapper' //v94 1084 }, 1085 }); 1086 } 1087 } 1088 }); 1089} 1090/** 1091 * Function to add requestforInfo,onSiteLink events to the dataLayer object for Card Grid Article - Curated 1092 */ 1093function trackArticleCardAnalytics() { 1094 setTimeout(() => { 1095 const articleLinks = document.querySelectorAll( 1096 '.enhancecardgridarticlesmanualcomponent a[button-tracking-value]' 1097 ); 1098 articleLinks.forEach(link => { 1099 link.addEventListener('click', function (event) { 1100 captureIIGButtonClick(event); 1101 }); 1102 }); 1103 }, 100); 1104} 1105/** 1106 * Function to add requestforInfo,onSiteLink events to the dataLayer object for Feature Curated (Feature Section Component) 1107 */ 1108function articleFeatureSectionAnalytics() { 1109 setTimeout(() => { 1110 const featureSectionLink = document.querySelectorAll( 1111 '.feature-section .feature_left_panel a.feature-card-article' 1112 ); 1113 featureSectionLink.forEach(link => { 1114 link.addEventListener('click', function (event) { 1115 captureIIGButtonClick(event); 1116 }); 1117 }); 1118 }, 100); 1119} 1120document.addEventListener('DOMContentLoaded', () => { 1121 const moreInsightsToggleSelector = '.more-insights-viewselect'; 1122 const insightsLibraryToggleSelector = '.insights-research-library-viewselect'; 1123 buttonInfoAnalytics(); 1124 clickRTELinkAnalytics(); 1125 clickIIGTextLinkAnalytics(); 1126 clickFspotAnalytics(); 1127 clickInfoAnalytics(); 1128 clickAdvisorFooterAnalytics(); 1129 insightsToggleButtonAnalytics(moreInsightsToggleSelector); 1130 insightsToggleButtonAnalytics(insightsLibraryToggleSelector); 1131 attestationModalButtonAnalytics(); 1132 carouselAnalytics(); 1133 vgAccordion(); 1134 trackGenericCarouselAnalytics(); 1135 clickEkitLoginAnalytics(); 1136 clickAdviceLoginAnalytics(); 1137 dataWrapperEvents(); 1138 trackArticleCardAnalytics(); 1139 articleFeatureSectionAnalytics(); 1140});
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.