Capture HubSpot Forms v4 iframe

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

Issue

The form is an iframe and is using the new HubSpot Forms v4 iframe, so we cannot capture the lead.

Solution

I added a custom script in WordPress’ RCFX Settings Footer to fire the RCFX capture event.

Put on the main site:
<script>
//Will only track forms made with the new form editor
window.addEventListener(‘hs-form-event:on-submission:success’, function(event){
console.log(“New form editor form submitted.”);
if(window.mcfx && window.HubspotFormsV4){
var fxForm = document.createElement(“form”);
fxForm.id = event.detail.formId;
//the HubspotFormsV4 interface can find the form that was just submitted by the event
HubspotFormsV4.getFormFromEvent(event).getFormFieldValues().then(function(response){
console.log(“Found form fields: “, response);
response.forEach(function(field){
var fxField = document.createElement(“input”);
fxField.name = field.name;
fxField.value = field.value;
fxForm.appendChild(fxField);
})
console.log(“Capturing form…”);
mcfx(‘capture’, fxForm);
console.log(“Form captured.”);
})
}
});
</script>

Achievement

The iframe lead is captured.

Snippet/Screenshot/Link

Task: Link

Code: Screenshot