1/* 2 * This file contains the code related to google tag manager (GTM) 3 * 4 */ 5// <!-- Data Layer --> 6var dataLayer = []; 7// <!-- End Data Layer --> 8 9var formFieldInteractionStr='formFieldInteraction'; 10var secureStr = 'secure'; 11var memberStr = 'member'; 12var employerStr = 'employer'; 13var selfEmployedStr = 'self-employed'; 14var advisorStr = 'advisor'; 15var representativeStr = 'representative'; 16var optOutStr = 'opt-out'; 17 18function logDebugMessage(message) { 19 //alert(message); 20 /* 21 if(console) { 22 console.log(message); 23 } 24 */ 25} 26/* 27 * this function put the json data into the dataLayer array object 28 */ 29function pushIntoDatalayer(jsonData){ 30 /* 31 if(JSON) { 32 logDebugMessage('pushIntoDatalayer !!! ' + JSON.stringify(jsonData)); 33 } 34 */ 35 if(isGDPRAccepted()){ //GDPR CR511 REQUIREMENT 36 if( dataLayer ) { 37 //alert("In dataLayer"); 38 dataLayer.push(jsonData); 39 } 40 } 41} 42 43function createAndPushPageLoadData(siteSectionValue, registrationTypeValue, userHashValue) { 44 45 46 47 if(isGDPRAccepted()){ //GDPR CR511 REQUIREMENT 48 // retrieve partyId from cookie, if not available then set undefined 49 userHashValue = ($.cookie('partyID') == undefined) ? undefined : $.cookie('partyID'); 50 51 var pageLoadJsonData1 = { }; 52 pageLoadJsonData1['siteSection'] = siteSectionValue; 53 pageLoadJsonData1['registrationType'] = registrationTypeValue; 54 pageLoadJsonData1['userHash'] = userHashValue; 55 56 pushIntoDatalayer(pageLoadJsonData1); 57 } 58} 59 60//1208904--start 61function createAndPushPartyIdOnPageLoad(userHashValue) { 62 63 // retrieve partyId from cookie, if not available then set undefined 64 if(isGDPRAccepted()){ //GDPR CR511 REQUIREMENT 65 userHashValue = ($.cookie('partyID') == undefined) ? undefined : $.cookie('partyID'); 66 67 var pageLoadJsonData = { }; 68 pageLoadJsonData['userHash'] = userHashValue; 69 70 71 pushIntoDatalayer(pageLoadJsonData); 72 } 73} 74 75//1208904--end 76/* 77 * Method to create json object of Form field event 78 */ 79 80 81function createAndPushFormFieldEventDataToGTM(formFieldEventName, formFieldName) { 82 83 if(isGDPRAccepted()){ //GDPR CR511 REQUIREMENT 84 logDebugMessage('createAndPushFormFieldEventDataToGTM : ' +formFieldEventName+ ' :: ' + formFieldName); 85 var interactionEventJsonData = { }; 86 interactionEventJsonData['event'] = formFieldEventName; 87 interactionEventJsonData['fieldName'] = formFieldName; 88 89 pushIntoDatalayer(interactionEventJsonData); 90 interactionEventJsonData = null; 91 } 92} 93 94/* 95 * Method to create json object of lightbox display event 96 */ 97 98 99function createAndPushLightBoxDisplayEventDataToGTM(lightBoxName) { 100 if(isGDPRAccepted()){ //GDPR CR511 REQUIREMENT 101 logDebugMessage('createAndPushLightBoxDisplayEventDataToGTM - lightBoxName : ' + lightBoxName); 102 if(lightBoxName == '' || lightBoxName == undefined || lightBoxName == null) { 103 return; 104 } 105 106 var interactionEventJsonData = { }; 107 interactionEventJsonData['event'] = 'lightboxDisplayed'; 108 interactionEventJsonData['lightboxName'] = lightBoxName; 109 110 pushIntoDatalayer(interactionEventJsonData); 111 interactionEventJsonData = null; 112 } 113} 114 115 116/* 117 * Method to create json object of lightbox button event 118 */ 119 120function createAndPushLightBoxButtonEventDataToGTM(lightBoxName, lightBoxButtonName) { 121 if(isGDPRAccepted()){ //GDPR CR511 REQUIREMENT 122 logDebugMessage('createAndPushLightBoxButtonEventDataToGTM - lightBoxName : ' + lightBoxName); 123 if(lightBoxName === '' || lightBoxName == undefined || lightBoxName == null) { 124 return; 125 } 126 127 var interactionEventJsonData = { }; 128 interactionEventJsonData['event'] = 'lightboxButtonSelected'; 129 interactionEventJsonData['lightboxName'] = lightBoxName; 130 interactionEventJsonData['lightboxButton'] = lightBoxButtonName; 131 132 pushIntoDatalayer(interactionEventJsonData); 133 interactionEventJsonData = null; 134 } 135} 136 137 138/* 139 * Method to create json object of help selection 140 */ 141 142function createAndPushHelpSelectedEventDataToGTM(fieldName) { 143 144 if(isGDPRAccepted()){ //GDPR CR511 REQUIREMENT 145 var interactionEventJsonData = { }; 146 interactionEventJsonData['event'] = 'formFieldHelpSelected'; 147 interactionEventJsonData['fieldName'] = fieldName; 148 149 pushIntoDatalayer(interactionEventJsonData); 150 logDebugMessage('pushing page HelpSelectedEvent !'); 151 } 152} 153 154 155/* 156 Error message to be pushed into dataLayer when style is display:block. 157 dataLayer.push({ 158 event: 'formFieldError', 159 fieldName: '[fieldName]', 160 fieldError: '[fieldError]' 161 });
162 */ 163 164function logSignupAsEmployerFirstNameErrorEvent(data){ 165 if(isGDPRAccepted()){ //GDPR CR511 REQUIREMENT 166 logDebugMessage('data.status : ' + data.status); 167 if(data.status === 'success' ) { 168 var mandatoryFirstNameDiv = document.getElementById('signupAsEmployer:yourFirstNameTxtId_hiddenId').value; 169 // mandatoryFirstNameDiv should be 'none' or 'block' 170 logDebugMessage('send mandatoryFirstNameDiv value :: ' + mandatoryFirstNameDiv +' :: to GTM '); 171 172 pushIntoDatalayer({ 173 event: 'formFieldError', 174 fieldName: 'firstName', 175 fieldError: 'Enter first name please !' 176 }); 177 // dataLayer.push(); 178 179 str = JSON.stringify(dataLayer); 180 str = JSON.stringify(dataLayer, null, 4); // (Optional) beautiful indented output. 181 logDebugMessage('is window.console :: ' + window.console); 182 logDebugMessage('is log :: ' + window.console.log); 183 if(window.console) { 184 window.console.log('dataLayer str :: ' + str); // Displays output using window.//alert() 185 } 186 logDebugMessage('dataLayer str :: ' + str); 187 } 188 } 189} 190 191 192// following function is used in pafadd.xhtml file 193 194 195function logEventsToGTM(formField){ 196 197( function (id,type) { 198 var functions = { 199 addressRadioGtm : function() { 200 createAndPushFormFieldEventDataToGTM(formFieldInteractionStr,id.split(':')[id.split(':').length - 2]); 201 logDebugMessage('addressRadioGtm : ' + formFieldInteractionStr + ' >>> '+ id.split('.')[id.split('.').length - 2]); 202 }, 203 204 addressTextGtm : function() { 205 createAndPushFormFieldEventDataToGTM(formFieldInteractionStr,id.split(':')[id.split(':').length - 1]); 206 logDebugMessage('addressTextGtm called' + formFieldInteractionStr + ' >>> '+ id.split('.')[id.split('.').length - 2]); 207 } 208 }; 209 return (type == 'radio') ? functions['addressRadioGtm'] : functions['addressTextGtm']; 210}) 211($(formField).attr('id'), $(formField).attr('type')) 212(); 213 214} 215 216 217function pushLoginEventDataToGTM(eventName) { 218 if(isGDPRAccepted()){ //GDPR CR511 REQUIREMENT 219 logDebugMessage('pushLoginEventDataToGTM : ' + eventName); 220 var interactionEventJsonData = { }; 221 interactionEventJsonData['event'] = eventName; 222 223 pushIntoDatalayer(interactionEventJsonData); 224 } 225} 226 227/* 228 * Method to create json object of Form field event 229 */ 230 231 232function logErrorEventTOGTM(formFieldName, errorMessage) { 233 234 if(isGDPRAccepted()){ //GDPR CR511 REQUIREMENT 235 if(!formFieldName || !errorMessage) { 236 return; 237 } 238 logDebugMessage('createAndPushFormFieldEventDataToGTM : ' + formFieldName + ' :: ' + errorMessage); 239 var interactionEventJsonData = { }; 240 interactionEventJsonData['event'] = 'formFieldError'; 241 interactionEventJsonData['fieldName'] = formFieldName; 242 interactionEventJsonData['fieldError'] = errorMessage; 243 244 pushIntoDatalayer(interactionEventJsonData); 245 interactionEventJsonData = null; 246 } 247} 248 249/* non ajax server side error messages logging 250 * The class name of the div is considered to be "field_error_msg <fieldName> <otherClassNames>" 251 * The second position fieldName in the class name list is dummy one - only use to get fieldName 252 */ 253function onLoadLogNonAjaxServerSideErrors() { 254 if(isGDPRAccepted()){ //GDPR CR511 REQUIREMENT 255 var nonAjaxMsgElements = $(".field_error_msg > .error_box_sub > p"); 256 var errorMessage = null; 257 var fieldNameStr = null; 258 259 for (i = 0; i < nonAjaxMsgElements.length; i++) { 260 errorMessage = nonAjaxMsgElements[i].innerHTML; 261 fieldNameStr = (nonAjaxMsgElements[i].parentElement.parentElement.className).split(/\s+/)[1]; 262 console.log('name:' + fieldNameStr + ' > message: ' + errorMessage); 263 logErrorEventTOGTM(fieldNameStr, errorMessage); 264 } 265 } 266} 267 268 269function logPostCodeErrorEvent(data){ 270 if(isGDPRAccepted()){ //GDPR CR511 REQUIREMENT 271 if(data.status === 'success' ) { 272 try { 273 var postCodeErrorDiv = $("div.findPostcodeGTM"); 274 var displayStr = postCodeErrorDiv.css('display'); 275 var msgStr = postCodeErrorDiv[0].innerHTML.trim(); 276 277 if(displayStr == 'block') { 278 //console.log('>>>' + displayStr + '>>>' + postCodeErrorDiv[0].innerHTML.trim() ); 279 logErrorEventTOGTM('postCode',msgStr); 280 } 281 } catch(err){ 282 //console.log(err); 283 } 284 } 285 } 286} 287 288// ajax response status based error log to GTM 289 290 291function logDelegatedSignupTmpCdErrorToGTM(data){ 292 if(isGDPRAccepted()){ //GDPR CR511 REQUIREMENT 293 if(data.status == 'success' ) { 294 if(document.getElementById("delegatedAccessSignUp:mandatoryUnique_id").style.display == 'block'){ 295 logErrorEventTOGTM('Temporary Access Code', document.getElementById("delegatedAccessSignUp:mandatoryUnique_id").children[0].innerHTML); 296 } 297 } 298 } 299} 300 301//ajax response status based error log to GTM 302 303 304function logDelegatedSignupEmailErrorToGTM(data){ 305 if(isGDPRAccepted()){ //GDPR CR511 REQUIREMENT 306 if(data.status === 'success' ) { 307 if(document.getElementById("delegatedAccessSignUp:mail_id").style.display == 'block'){ 308 logErrorEventTOGTM('Email Address', document.getElementById("delegatedAccessSignUp:mail_id").children[0].innerHTML); 309 } 310 } 311 } 312} 313 314 315//ajax response status based error log to GTM 316 317 318function logSignupSelfEmpDOBErrorToGTM(data){ 319 if(isGDPRAccepted()){ //GDPR CR511 REQUIREMENT 320 if(data.status === 'success' ) { 321 if(document.getElementById("signupAsSelfEmployed:year_id1").style.display == 'block'){ 322 logErrorEventTOGTM('Date Of Birth', document.getElementById("signupAsSelfEmployed:year_id1").children[0].innerHTML); 323 }
324 if(document.getElementById("signupAsSelfEmployed:year_id2").style.display == 'block'){ 325 logErrorEventTOGTM('Date Of Birth', document.getElementById("signupAsSelfEmployed:year_id2").children[0].innerHTML); 326 } 327 if(document.getElementById("signupAsSelfEmployed:year_id3").style.display == 'block'){ 328 logErrorEventTOGTM('Date Of Birth', document.getElementById("signupAsSelfEmployed:year_id3").children[0].innerHTML); 329 } 330 if(document.getElementById("signupAsSelfEmployed:year_id4").style.display == 'block'){ 331 logErrorEventTOGTM('Date Of Birth', document.getElementById("signupAsSelfEmployed:year_id4").children[0].innerHTML); 332 } 333 } 334 } 335} 336 337 338//ajax response status based error log to GTM 339 340 341function logSignupSelfEmpNIErrorToGTM(data){ 342 343 if(isGDPRAccepted()){ //GDPR CR511 REQUIREMENT 344 if(data.status === 'success' ) { 345 if(document.getElementById("signupAsSelfEmployed:NinoChk_id").style.display == 'block'){ 346 logErrorEventTOGTM('National Insurance Number', document.getElementById("signupAsSelfEmployed:NinoChk_id").children[0].innerHTML); 347 } 348 } 349 } 350} 351 352//ajax response status based error log to GTM 353 354 355function logActivateAccountNestIDErrorToGTM(data){ 356 357 if(isGDPRAccepted()){ //GDPR CR511 REQUIREMENT 358 if(data.status === 'success' ) { 359 if(document.getElementById("activateYourAccount:nest_id").style.display == 'block'){ 360 logErrorEventTOGTM('National Insurance Number', document.getElementById("activateYourAccount:nest_id").children[0].innerHTML); 361 } 362 } 363 } 364} 365function createAndPushEventDataToGTM(fieldEventName) { 366 if(isGDPRAccepted()){ //GDPR CR511 REQUIREMENT 367 logDebugMessage('createAndPushEventDataToGTM : ' +fieldEventName); 368 var interactionEventJsonData = { }; 369 if((fieldEventName.search("_action") > 0) || (fieldEventName.search("_button") > 0) || (fieldEventName.search("_tab") > 0) || (fieldEventName.search("_link") > 0) ){ 370 var button_track = "button_track"; 371 interactionEventJsonData['event'] = fieldEventName; 372 interactionEventJsonData['button_name'] = fieldEventName; 373 interactionEventJsonData['track_type'] = button_track; 374 } 375 else{ 376 interactionEventJsonData['event'] = fieldEventName; 377//add here 378 379 if(fieldEventName == "Header_text_size_A-"){ 380 interactionEventJsonData['accessibilityOption'] = 'Font Small'; 381 } 382 if(fieldEventName == "Header_text_size_A"){ 383 interactionEventJsonData['accessibilityOption'] = 'Font Normal'; 384 } 385 386 if(fieldEventName == "Header_text_size_A+"){ 387 interactionEventJsonData['accessibilityOption'] = 'Font Large'; 388 } 389 390 //add here 391 392 } 393 pushIntoDatalayer(interactionEventJsonData); 394 interactionEventJsonData = null; 395 } 396 } 397 398function callCustomTag(tagEvent) { 399 400 if(isGDPRAccepted()){ //GDPR CR511 REQUIREMENT 401 return createAndPushEventDataToGTM(tagEvent); 402 } 403 404} 405function isGDPRAccepted() { 406 //gdprStatus = ($.cookie('policy') == 'analyticsCookies%3Don%26functionalityCookies%3Don') ? true : false; 407 gdprStatus=checkUserConsent(); 408 //alert("***gdprStatus ="+gdprStatus); 409 return gdprStatus; 410} 411 412 413
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.