Ina recent post, you learned that having multiple form embeds in the same page, withloadFormcalled 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 predictwhichform(s) will fail on a given pageview.)
The solution is toload all forms from the same domain, preferably your LP domain.[1]
But there’s one case when you can’t do that: when you’re deliberately loading embeds fromdifferent 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 ofMktoForms2for each domain. This will in turn createa separate IFRAME for each instance of the library, so they can submit side-by-side.
RunningMktoForms2SxS
This task issuperficiallysimple: you’d think you could delete the globalMktoForms2before 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-crazyForms 2.0 Instance Manager. Pretty proud of it, gotta admit... good to flex the ol’Getter and Settermuscles.
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, firstget()the appropriate instance from the Manager. The methods are otherwise the same stuff from the Forms 2.0 API:
You can add eventsto all forms on all instances byforEach()-ing over the instances:
Or target a specific instance + form only if it’s present:
NOTES
[1] You could load them all from theapp-*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.