The client wants to track the Treatment & Admission Inquiries form, but it has sensitive data, and we need to comply with HIPAA.
I constructed a custom code that will clone the form and exclude unwanted input data value.
/* Constructed a Clone form to exclude HIPAA inputs */
(function() {
// Fields to exclude from cloning
var excludedFields = new Set([
'field146345587',
'field146345644',
'field146734075',
'field146740569',
'field146345571-first',
'field146345571-last'
]);
var fxform = document.querySelector('form#fsForm5327511');
console.log('form found' + ' ' + fxform);
if (fxform) {
var submitButton = fxform.querySelector('#fsSubmitButton5327511');
console.log('button found' + ' ' + submitButton);
if (submitButton) {
submitButton.addEventListener('click', function() {
console.log('submit button clicked');
var virtualForm = document.createElement('form');
virtualForm.setAttribute('id', 'fx-admissions-inquiry');
fxform.querySelectorAll('input, textarea, select').forEach(function(field, index) {
// Skip excluded fields
if (excludedFields.has(field.getAttribute('name')) ||
excludedFields.has(field.getAttribute('id'))) {
console.log('Skipping excluded field:', field.getAttribute('name') || field.getAttribute('id'));
return;
}
var fxfield = field.cloneNode(true);
if (!fxfield.getAttribute('name')) {
fxfield.setAttribute('name', 'fx-' + index);
}
virtualForm.appendChild(fxfield);
});
mcfx('capture', virtualForm);
console.log(virtualForm);
});
}
}
})();
Constructed a custom tracking that excludes sensitive data for the Treatment & Admission Inquiries form and the leads are captured as requested.