How to delay code from executing until Marketo form render has fully executed?
I have a situation where we are executing some code on pages that have Marketo forms. This particular piece of code handles a few things. One it takes care of multiple Marketo forms on the same page but it also pushes data, we've designated in our CMS, to the dataLayer along with the form render on a successful submission of the form. Now, this code, which is being executed through Google Tag Manager, currently uses an element visibility trigger. It looks for the mktForm class. When that class is present the code executes. The problem is that this code may execute before we're done retrieving the Marketo form and fully rendering it. This ends up popping an error message. What I am thinking would solve this issue is instead of triggering the code with a element visibility trigger it would be best to wait until the form is fully rendered. This probably needs some JS(or maybe not) to see if this 'fully rendered' condition exists but I not sure how to do this. Any help would be greatly appreciated.