function(){
var found = false;
var intervalId;
function checkElementOnPage() {
var elements = document.getElementsByClassName("GetConsultationForm_successMessageSection__c2EeU");
if (elements.length > 0 && !found) {
console.log("Success message found on page");
window.dataLayer.push({'event': 'formSubmissionSuccess'});
found = true;
clearInterval(intervalId);
}
}
var intervalId = setInterval(checkElementOnPage, 30000);
return undefined;
}
function checkForSuccessMessage() {
var found = false;
var targetNode = document.body;
var config = { childList: true, subtree: true };
var callback = function(mutationsList, observer) {
mutationsList.forEach(function(mutation) {
if (mutation.type === 'childList') {
var elements = document.getElementsByClassName("sent");
if (elements.length > 0 && !found) {
console.log("Success message found on page");
window.dataLayer.push({'event': 'deepak'});
found = true;
observer.disconnect();
}
}
});
}
var observer = new MutationObserver(callback);
observer.observe(targetNode, config);
return found;
}
Class/Element Visibility tracker - Google tag manager
- on Tuesday, February 7, 2023, , 9:25 PM
- No comments
Virender Bartwal
I am a digital marketing professional dedicated to assisting businesses in achieving success in the online realm ! With more than 10 yrs of hands-on experience in various areas such as SEO, local SEO, Analytics, and WordPress development, I have acquired a wealth of knowledge and proficiency. Additionally, I maintain this blog where I delve into these subjects, constantly seeking innovative methods to disseminate my expertise among fellow enthusiasts.
Twitter | LinkedIn | Website
Twitter | LinkedIn | Website