Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Sm1pleScr1pt committed Dec 18, 2024
2 parents c1fb739 + d0f1ea5 commit 0977a6e
Show file tree
Hide file tree
Showing 9 changed files with 160 additions and 72 deletions.
8 changes: 6 additions & 2 deletions blocks/accordion-group/accordion-group.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ctaClickInteraction, documentRequiredInteraction, faqInteraction } from '../../dl.js';
import { ctaClick, ctaClickInteraction, documentRequiredInteraction, faqInteraction } from '../../dl.js';
import { fetchPlaceholders } from '../../scripts/aem.js';
import { targetObject } from '../../scripts/scripts.js';
import { documentRequired, generateAccordionDOM } from '../accordion/accordion.js';
Expand Down Expand Up @@ -43,7 +43,7 @@ function openFunctionFAQ(block) {
const titles = block.querySelectorAll('details summary');

titles.forEach((title) => {
title.addEventListener('click', function () {
title.addEventListener('click', function (e) {
if (this.classList.contains('active')) {
setTimeout(() => {
this.closest('details').removeAttribute('open');
Expand All @@ -61,6 +61,10 @@ function openFunctionFAQ(block) {
if (title.closest('.documents-required-brown')) {
dataAnalytics.click_text = title.querySelector('h3').textContent.trim();
documentRequiredInteraction(dataAnalytics);
const click_text = title.querySelector('h3').textContent.trim();
const cta_position = '';
const cta_category = title.closest('.section').querySelector('.default-content-wrapper').querySelector('h1, h2, h3, h4, h5, h6').textContent.trim();
ctaClick(click_text, cta_category, cta_position, targetObject.pageName);
} else {
dataAnalytics.click_text = title.textContent.trim();
faqInteraction(dataAnalytics);
Expand Down
2 changes: 2 additions & 0 deletions blocks/applyloanform/applyloanforms.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,10 @@ export function applyLoanFormClick() {
const ctaPos = e.target?.closest('.section')?.querySelector('.calculator-parent p')?.textContent.trim();
if (e.target.innerText.trim() === 'Talk to loan expert') {
talkToExpert('calculator', emiName, ctaPos, targetObject.pageName);
formInteraction(emiName,"Form Open",targetObject.pageName)
} else if (e.target.innerText.trim() === 'Apply loan now') {
applyLoanNow('calculator', emiName, ctaPos, targetObject.pageName);
formInteraction(targetObject.pageName,"Form Open",targetObject.pageName)
}
// console.log("calculator type : ", targetObject.calculatorType);
} catch (error) {
Expand Down
21 changes: 14 additions & 7 deletions blocks/applyloanform/loanformapi.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// import { ProductLogics } from "./loadformlogic";
// import { otpPopupFailureFun, removeLoader } from "../../../../clientlibs/support/otppopup/js/otppopup";
import {
errorPopUp, formInteraction, generateLead, resendOtp, thankYouPopUp, verifyOtp,
errorPopUp, formInteraction, generateLead, lpOtpValidate, resendOtp, thankYouPopUp, verifyOtp,
} from '../../dl.js';
import { fetchAPI, targetObject } from '../../scripts/scripts.js';
import {
Expand Down Expand Up @@ -40,6 +40,7 @@ export function buttonCLick() {
try {
updateFormValuve();
formInteraction(formLoanType, 'Form Submit', targetObject.pageName);
generateLead(formName, formLoanType, formLoanAmount, formState, formBranchCity, targetObject.pageName);
} catch (error) {
console.warn(error);
}
Expand Down Expand Up @@ -314,8 +315,14 @@ function verifyOtpBtnClick() {
verifyOtpBtn.addEventListener('click', (e) => {
updateFormValuve();
const otpValue = document.querySelector('#loan-form-otp-input').value;
verifyOtpBtn.closest('.loan-form-button-container').classList.add('loader-initialized');
verifyOtpBtn.closest('.loan-form-button-container').classList.add('loader-initialized');
formInteraction(formLoanType, 'verify', targetObject.pageName);
try {
const click_text = e.target.textContent.trim() || "";
lpOtpValidate(click_text,formLoanType,targetObject.pageName)
} catch (error) {
console.log(error)
}
if (otpValue) {
verfyOtpAPI(otpValue)
.then(({ returnResponse, authUniqueId }) => {
Expand All @@ -333,11 +340,11 @@ function verifyOtpBtnClick() {
if (ProductLogics(loanFormCriteria())) {
loaninnerform.classList.add('loan-form-success');
loanStatus = 'Approved';
try {
generateLead(formName, formLoanType, formLoanAmount, formState, formBranchCity, targetObject.pageName);
} catch (error) {
console.warn(error);
}
// try {
// generateLead(formName, formLoanType, formLoanAmount, formState, formBranchCity, targetObject.pageName);
// } catch (error) {
// console.warn(error);
// }
try {
thankYouPopUp(formName, formLoanType, targetObject.pageName);
} catch (error) {
Expand Down
2 changes: 1 addition & 1 deletion blocks/header/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ export default async function decorate(block) {
if (e.target.tagName == 'IMG' || e.target.querySelector('icon-language')) {
click_text = e.target.getAttribute('data-icon-name');
} else {
click_text = e.target.innerText;
click_text = e.target.textContent.trim();
}
const menu_category = e.target.closest('ul').closest('li')?.querySelector('p')?.innerText || '';
targetObject.ctaPosition = 'Top Menu Bar';
Expand Down
11 changes: 10 additions & 1 deletion blocks/homeloancalculatorv2/homeloancalculators.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { currenyCommaSeperation } from '../../scripts/scripts.js';
import { ctaClick } from '../../dl.js';
import { currenyCommaSeperation, targetObject } from '../../scripts/scripts.js';
import { renderCalculatorData } from './renderhpcal.js';
import { resetCalculator } from './resetCalculator.js';

Expand Down Expand Up @@ -26,6 +27,14 @@ export function homeLoanCalcFunc(currentSection) {
});

function handleTabClick(tabDiv, isSalaried, index) {
try {
const click_text = tabDiv.textContent.trim();
const cta_position = '';
const cta_category = tabDiv.closest('.section')?.previousElementSibling.querySelector(".default-content-wrapper").querySelector('h1, h2, h3, h4, h5, h6').textContent.trim() || '';
ctaClick(click_text, cta_category, cta_position, targetObject.pageName);
} catch (error) {
console.log(error);
}
const backgroundDiv = tabDiv.closest('.home-loan-calculator-parent');
const calculatorDiv = tabDiv.parentElement.closest('.home-loan-calculator-parent ').nextElementSibling;
const radioInput = isSalaried ? salariedRadios[index] : businessRadios[index];
Expand Down
18 changes: 16 additions & 2 deletions blocks/keyfeatures/keyfeatures.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ctaClickInteraction, keyFeaturesInteraction } from '../../dl.js';
import { ctaClick, ctaClickInteraction, keyFeaturesInteraction } from '../../dl.js';
import { fetchPlaceholders } from '../../scripts/aem.js';
import { decoratePlaceholder, renderHelper } from '../../scripts/scripts.js';
import { decoratePlaceholder, renderHelper, targetObject } from '../../scripts/scripts.js';

export default async function decorate(block) {
block.innerHTML = await decoratePlaceholder(block);
Expand Down Expand Up @@ -195,6 +195,13 @@ export function featureDropDownClick(block) {
dataAnalytics.click_text = e.target.closest('.keyfeatures-wrapper')?.querySelector('.cmp-teaser__content p')?.textContent.trim();
dataAnalytics.cta_position = e.target.closest('.section')?.querySelector('.default-content-wrapper')?.textContent.trim();
keyFeaturesInteraction(dataAnalytics);
try {
const cta_position = '';
const cta_category = dataAnalytics.cta_position;
ctaClick(dataAnalytics.click_text, cta_category, cta_position, targetObject.pageName);
} catch (error) {
console.log(error);
}
keyfeaturesList.forEach((keyfeatures) => {
if (keyfeatures.style.display === 'none') {
keyfeatures.style.display = 'block';
Expand Down Expand Up @@ -304,6 +311,13 @@ function keyFeaturesAnalytics(block) {
data.click_text = e.target.closest('.cmp-teaser')?.querySelector('.cmp-teaser__content p')?.textContent.trim();
data.cta_position = e.target.closest('.section')?.querySelector('.default-content-wrapper strong')?.textContent.trim() || e.target.closest('.section')?.querySelector('.default-content-wrapper')?.textContent.trim();
keyFeaturesInteraction(data);
try {
const cta_position = '';
const cta_category = data.cta_position;
ctaClick(data.click_text, cta_category, cta_position, targetObject.pageName);
} catch (error) {
console.log(error);
}
});
});
}
10 changes: 9 additions & 1 deletion blocks/teaser/teaser.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {
applyLoanNow, bannerClick, ctaClickInteraction, readMoreInteraction,
applyLoanNow, bannerClick, ctaClick, ctaClickInteraction, readMoreInteraction,
} from '../../dl.js';
import { targetObject , handleOpenFormOnClick } from '../../scripts/scripts.js';

Expand Down Expand Up @@ -123,9 +123,17 @@ export function generateTeaserDOM(props, classes) {
el.addEventListener('click', function (e) {
try {
if (!e.target.closest('.calc-desktop-carousel-wrapper')) {
if(!e.target.closest(".multi-calc-teaser-wrapper")){
if (index || e.target.closest('.cta')) {
bannerClick(e.target.innerText, targetObject.pageName);
}
}
if(e.target.closest(".multi-calc-teaser-wrapper")){
const click_text = e.target.textContent.trim();
const cta_position = '';
const cta_category = e.target.closest('.foreground').querySelector('.long-description').querySelector('p') .textContent.trim()
ctaClick(click_text, cta_category, cta_position, targetObject.pageName);
}
if (e.target.closest('.open-form-on-click')) {
const formClickSection = e.target.closest('.open-form-on-click');
handleOpenFormOnClick(formClickSection);
Expand Down
15 changes: 14 additions & 1 deletion dl.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export function applyLoanNow(cta_category, loan_type, cta_position, page_type) {
export function ctaClick(click_text, cta_category, cta_position, page_type) {
try {
window.dataLayer.push({
event: 'cta_click',
event: 'cta_click',
click_text,
cta_category,
cta_position,
Expand Down Expand Up @@ -318,3 +318,16 @@ export function intertextLinkingInteraction(data) {
console.warn(error);
}
}

export function lpOtpValidate(click_text,loan_type,page_type){
try {
window.dataLayer.push({
event: 'LP_otp_validate',
click_text: click_text || '',
loan_type: loan_type || '',
page_type: page_type || ''
});
} catch (error) {
console.log(error);
}
}
Loading

0 comments on commit 0977a6e

Please sign in to comment.