Capture lead on a Wix nameless form

gerard_reyes Posted by: Gerard Reyes Date Posted: March 16, 2025
Back to Case Studies

Issue

Wix form’s inputs have no name. LMFX captures lead data using the name. The input ID is dynamic and changes every time.

Solution

Create a custom code to give a name to the inputs using its ID. We only use the ID partially because the ID changes every time. We cut off the part that changes and retain the consistent part.

// Function to assign custom names to inputs without names
function assignCustomNamesToInputs() {
    // Get all input elements on the page
    var inputs = document.querySelectorAll('input, textarea');

    // Loop through all input elements
    for (var i = 0; i < inputs.length; i++) {
        var input = inputs[i];

        // Check if the input element does not have a name attribute
        if (!input.name && input.id) {
            input.name = input.id.split('-:')[0];
        }
    }
}

// Call the function to execute it
    setInterval(function() {
    assignCustomNamesToInputs();
}, 1000); // 1000 milliseconds = 1 second

Achievement

The lead was captured.

Snippet/Screenshot/Link