Front App’s live chat widget is embedded via an srcdoc iframe. The chat greeting includes a form that collects the visitor’s name and email, but because it lives inside an iframe, standard tracking tools — including RCFX’s native forms module — couldn’t detect it. The widget is hidden outside of business hours, adding an extra layer of complexity.
Since the chat widget loads inside a special type of iframe, we were able to access its contents directly from the parent page. We used stable element identifiers built into the widget to detect when the form was ready, then attached a listener to the submit button. The solution was first validated in the browser console before being deployed in GTM.
The breakthrough came when we discovered that RCFX’s form capture function requires an actual page element to work — passing raw data values alone wasn’t enough. The fix was to quietly build a hidden form behind the scenes, fill it with the chat form values, hand it off to RCFX for capture, then remove it once done. The final script was deployed in GTM to fire automatically on all pages.
Turned a previously untrackable third-party chat form into a fully attributed lead capture in LMFX. The ghost form approach is reusable for any third-party widget that lives inside an srcdoc iframe where RCFX’s native forms module can’t reach. Any analyst can now deploy the GTM tag on similar setups without needing to reverse-engineer the mcfx API from scratch.
<script>
var checkForm = setInterval(function() {
var iframe = document.getElementById("front-chat-iframe");
if (!iframe || !iframe.contentDocument) return;
var btn = iframe.contentDocument.querySelector('[data-testid="custom-field-form-submit-button"]');
if (!btn) return;
clearInterval(checkForm);
console.log("Front Chat form found, listener attached.");
btn.addEventListener("click", function() {
var iframeDoc = document.getElementById("front-chat-iframe").contentDocument;
var inputs = iframeDoc.querySelectorAll('[data-testid="custom-field-form-input"]');
var virtualForm = {
name: inputs[0] ? inputs[0].value : "",
email: inputs[1] ? inputs[1].value : ""
};
var ghostForm = document.createElement("form");
ghostForm.style.display = "none";
ghostForm.id = "front-chat-virtual-form";
var nameInput = document.createElement("input");
nameInput.type = "text";
nameInput.name = "Name";
nameInput.value = virtualForm.name;
var emailInput = document.createElement("input");
emailInput.type = "email";
emailInput.name = "Email";
emailInput.value = virtualForm.email;
ghostForm.appendChild(nameInput);
ghostForm.appendChild(emailInput);
document.body.appendChild(ghostForm);
console.log("Front Chat Form Submit", virtualForm);
mcfx('capture', ghostForm);
document.body.removeChild(ghostForm);
});
}, 500);
</script>