HubSpot Tracking to exclude non-iframe forms to avoid duplicate leads

Posted by: Nico Cagalitan Date Posted: June 26, 2025
Back to Case Studies

Issue

We have encountered an issue where some clients are using HubSpot forms but embedding them directly and in an iframe, which poses a problem for our tracking. This is because iframe forms are not tracked by default and require a custom code to be implemented for those forms to be tracked.

The worst part is that if both embeds are being used and we add the custom code for iframe tracking, the ordinary embed will fire twice, thus creating duplicate leads.

 

Solution

Tweaked the HubSpot custom code to add an exclusion for non-iframe forms so those forms will not fire twice and will track normally.

Achievement

Able to track both HubSpot iframe and non-iframe forms without any issues or duplicates by excluding the non-iframe by tweaking the HubSpot custom code.

Snippet/Screenshot/Link

Ticket: link

Code: [screenshot]