In a recent post, you learned that having multiple form embeds in the same page, with loadForm called from more than one domain, causes fatal errors.
Those errors can break any form on the page, depending on load order. (I didn’t mention this explicitly before, but when multiple forms are injected via GTM or another async mechanism, you can’t predict the order — meaning you can’t even predict which form(s) will fail on a given pageview.)
The solution is to load all forms from the same domain, preferably your LP domain.
But there’s one case when you can’t do that: when you’re deliberately loading embeds from different Marketo instances. Not just different aliases for the same instance, but totally different instances, like one for B2B and one for B2C.
In this case, you can’t simply standardize on one domain. But what you can do is force the Forms 2.0 loader to create a separate instance of MktoForms2 for each domain. This will in turn create a separate IFRAME for each instance of the library, so they can submit side-by-side.
Running MktoForms2 SxS
This task is superficially simple: you’d think you could delete the global MktoForms2 before each embed, so the library will think it hasn’t been loaded yet. But that simple method doesn’t work in practice, due to a pesky problem with polyfills (such as the Input Mask and Date plugins).
So I ended up having to write this just-short-of-too-crazy Forms 2.0 Instance Manager. Pretty proud of it, gotta admit... good to flex the ol’ Getter and Setter muscles.
First, include the core function:
Then create an Instance Manager object, passing it your different instances’ URLs:
To load forms, add events, and so on, first get() the appropriate instance from the Manager. The methods are otherwise the same stuff from the Forms 2.0 API:
You can add events to all forms on all instances by forEach()-ing over the instances:
Or target a specific instance + form only if it’s present:
 You could load them all from the app-* domain, but then they’ll be blocked when Tracking Protection is on. So kill two birds with one stone and standardize on your LP domain.