Add a text to captured lead

gerard_reyes Posted by: Gerard Reyes Date Posted: January 19, 2026
Back to Case Studies

Issue

The tracking is working as expeted and capturing all input elements. But the client wants to captures a text in the website. The problem is the text is just a simple text and not an input element so LMFX does not capture those. Screenshot

Solution

I wrote custom JavaScript to capture the text clients want. Then I added the text to the capture form

Note: For some reason, the code does not appear if use a formatted code. So, I will paste the code without format.

mcfx(function(t) {
t.configure(“onFormCapture”, function(form) {
console.log(‘MCFX onFormCapture’);
console.log(form);

var customIdCounter = 1;
var elements = form.querySelectorAll(‘input, select, textarea’);

for (var i = 0; i < elements.length; i++) {
var element = elements[i];

if (!element.name) {
element.name = element.id ? element.id : ‘rcfx-custom-id-‘ + (customIdCounter++);
}
}

if (window.location.href.indexOf(‘build-your-led-wall’) !== -1) {
form.classList.add(‘rcfx-custom-class-build-your-led-wall’);

var headings = document.querySelectorAll(‘h4’);
var configurationDiv;

for (var i = 0; i < headings.length; i++) {
if (headings[i].textContent.trim() === ‘Your Configuration’) {
configurationDiv = headings[i].nextElementSibling;
break;
}
}

if (configurationDiv) {
var panel = configurationDiv.children[0].textContent.split(‘: ‘)[1];
var size = configurationDiv.children[1].textContent.split(‘: ‘)[1];
var pixelPitch = configurationDiv.children[2].textContent.split(‘: ‘)[1];
var pixels = configurationDiv.children[3].textContent.split(‘: ‘)[1];

var panelInput = document.createElement(‘input’);
panelInput.type = ‘hidden’;
panelInput.name = ‘panel’;
panelInput.value = panel;
form.appendChild(panelInput);

var sizeInput = document.createElement(‘input’);
sizeInput.type = ‘hidden’;
sizeInput.name = ‘size’;
sizeInput.value = size;
form.appendChild(sizeInput);

var pixelPitchInput = document.createElement(‘input’);
pixelPitchInput.type = ‘hidden’;
pixelPitchInput.name = ‘pixelPitch’;
pixelPitchInput.value = pixelPitch;
form.appendChild(pixelPitchInput);

var pixelsInput = document.createElement(‘input’);
pixelsInput.type = ‘hidden’;
pixelsInput.name = ‘pixels’;
pixelsInput.value = pixels;
form.appendChild(pixelsInput);
}
}
});
});

Achievement

The lead is captured along with the desired details.

Snippet/Screenshot/Link

Task: Link

Code: Screenshot