The form is using a NetSuite iFrame and is not being captured.
Two codes need to be added for this form to be captured:
I put a postMessage code in Netsuite > Setup > Other Setup > Online Customer Form > Custom Code > Click the open new window of script file > Media Item > Edit:
(function() {
//console.log(‘iframe postMessage’);
document.addEventListener(‘click’, function(event) {
// Log the clicked element
//console.log(‘Clicked element:’, event.target);
// Check if the clicked element is a button and has a value of ‘submit’
if (event.target.tagName === ‘INPUT’ && event.target.type === ‘submit’) {
//console.log(‘Submit button clicked!’);
var fxForm = event.target.closest(‘form’).cloneNode(true);
//fxForm.id = ‘rcfx_custom_id_career’;
fxForm.querySelectorAll(‘form input,textarea,select’).forEach(function(item) {
if (item.tagName === ‘TEXTAREA’) {
item.textContent = item.value; // Embed the value in the textContent
} else if (item.tagName === ‘SELECT’) {
var selectElement = document.getElementById(item.id);
var initialSelectedValue = selectElement.options[selectElement.selectedIndex].value;
//console.log(‘Initially selected value:’, initialSelectedValue);
var selectedText = Array.prototype.slice.call(selectElement.options).find(function(option) {
return option.value === initialSelectedValue;
}).text;
item.setAttribute(‘value’, selectedText);
item.setAttribute(‘data-value’, selectedText);
// Create a new hidden input element
var hiddenInput = document.createElement(‘input’);
hiddenInput.type = ‘hidden’;
hiddenInput.name = ‘rcfx-custom-‘ + item.id;
hiddenInput.value = selectedText;
fxForm.appendChild(hiddenInput);
} else {
item.setAttribute(‘value’, item.value);
item.setAttribute(‘data-value’, item.value);
}
});
//console.log(fxForm);
var mess = {
event: ‘fx-pardot’,
url: window.location.pathname,
theID: fxForm.getAttribute(‘id’),
theForm: fxForm.innerHTML
};
window.parent.postMessage(JSON.stringify(mess), ‘*’);
}
});
})();
I put postMessage listener in WordPress RCFX Settings:
window.addEventListener(‘message’, function(event) {
try {
var dat = JSON.parse(event.data);
if (dat.event == ‘fx-pardot’) {
var theForm = dat.theForm;
var fxForm = document.createElement(‘form’);
fxForm.innerHTML = theForm;
fxForm.setAttribute(‘id’, dat.url.substring(dat.url.lastIndexOf(‘/’) + 1, dat.url.length));
//fxForm.setAttribute(‘id’, dat.theID);
console.log(fxForm);
fxForm.querySelectorAll(‘form select option’).forEach(function(item) {
//item.setAttribute(‘value’, item.innerText);
//item.setAttribute(‘data-value’, item.innerText);
});
window.dataLayer.push({
event: ‘fx-pardot’
});
mcfx(‘capture’, fxForm);
console.log(‘RCFX capture success’);
}
} catch (e) {}
});
The lead from Netsuite iFrame is captured.
Task: Link
Code: Screenshot1, Screenshot2