Initially, the form is not firing the RCFX lead capture function. I added a custom code to fir the RCFX lead capture.
However, my code fires on site load. But the client’s site does not reload on navigating of site but rather loads asynchronously. The result of this is my code is not firing for the new page navigated to.
Example, if a user moved from the Contact Us page to the Get Quote page. My custom code only fires for the Contact Us page and not on the Get Quote page.
I modified the code to fire regardless of the navigation of the site.
// Function to assign custom names to inputs without names
function assignCustomNamesToInputs() {
var inputs = document.querySelectorAll('input, textarea');
var counter = 0;
for (var i = 0; i < inputs.length; i++) {
var input = inputs[i];
if (!input.name && input.id) {
input.name = input.id.split('-:')[0];
counter++;
}
}
}
// Call the function to execute it
setInterval(function() {
assignCustomNamesToInputs();
}, 1000); // 1000 milliseconds = 1 second
The custom code is firing and captures the lead.
Task: Link
Code: Screenshot