My company is a little late in the game to implementing Forms 2.0 because we’re concerned about integrating it with functionality that collects Google Adwords/Analytics tracking information on external pages. In the Forms 1.0 environment, we would get the form HTML code per Marketo’s instructions and place it on our page. In the form, we had a special field that was used by a third-party script to populate GA info from cookies.
With Forms 2.0, even though that field is still included as part of the form this mechanism will no longer work. In form 2.0 the code is embedded (*read – loaded dynamically via AJAX) in external pages. This breaks our approach as the tracking script on our webpages which collects the info from cookies doesn’t see a special field in the form at page load because the form is still not loaded and the field doesn’t exist in the DOM. The tracking script on our page is self-invoking and it runs when the page is loaded, and I'm not sure we can modify it to wait for a specific value to be present in the DOM (* third party script, obfuscated code, cross domain issues).
Is anyone else facing this issue or something similar and if so, can you share how your company handled it?
With Forms 2.0, if you have code that is dependent on the FORM tag being in the DOM, run this code from the form's onReady (the 4th argument to MktoForms2.loadForm).
While other approaches such as DOM Mutation Events/Observers may provide partial relief, they're basically doomed to failure especially in older browsers.
This is very helpful. Thank you so much!
Sanford is correct. You should be able to accomplish the same purpose inside of the embedded form script using the resources here: