Capture only specific inputs

gerard_reyes Posted by: Gerard Reyes Date Posted: October 21, 2025
Back to Case Studies

Issue

For legal purposes, we can only track specific sections of this form.

Solution

Created a custom code to filter out what inputs LMFX will capture and what will not.

 

Achievement

Lead is captured with the specific inputs only.

<script>
mcfx(function(t) {
t.configure("onFormCapture", function(form) {
console.log('MCFX onFormCapture');
//console.log(form);

var elements = form.querySelectorAll('input, select, textarea');
form.id = 'rcfx-custom-id-refer-a-patient';
for (var i = 0; i < elements.length; i++) {
var element = elements[i];
var name = element.getAttribute('name');
var id = element.getAttribute('id');

if (id !== 'phone' && id !== 'Email' && id !== 'field') {
element.parentNode.removeChild(element);
} else if (id === 'phone') {
element.setAttribute('name', 'phone-number');
} else if (id === 'field') {
element.setAttribute('name', 'date-of-birth');
}
}
});
});
</script>

Snippet/Screenshot/Link

Task: Link

Code: Screenshot