Embedding Marketo Forms on Build rather than on Page Load | Community
Skip to main content
Alex_O_Regan
Level 2
May 3, 2018
Question

Embedding Marketo Forms on Build rather than on Page Load

  • May 3, 2018
  • 2 replies
  • 5287 views

Hi,

I'm a web developer working at a company that wishes to use Marketo forms on it's website.

I've successfully gotten Marketo Forms integrated into the website, however, the load times for these embed scripts are unacceptably slow, and cause the website to feel clunky.

My possible solution for this is to execute the embed script during the website build, and then inject the returned form into the static webpage, so that the form will be served as static HTML, along with the rest of the page. However, I'm worried that when it comes to the client interacting with the form, the MktoForms2 script might not be able to detect that the form is already in the webpage.

Does anyone know if this solution will work? I'd like to know now, rather than starting the work only to realise that it's impossible. Any help is appreciated.

Regards.

Alex

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

2 replies

Josh_Hill13
Level 10
May 3, 2018

Sanford Whiteman​ ?

Consider using API for this instead.

SanfordWhiteman
Level 10
May 3, 2018

Inlining the entire form as HTML will absolutely not work.

You can inline the JSON form descriptor ​however (which is how forms work on Marketo-hosted LPs) and enhance the load time. I explained the process here: Smoothing embedded Marketo form loads

Alex_O_Regan
Level 2
May 4, 2018

Thanks guys for your help and advice, that being said, I'm pretty disappointed with Marketo Forms as a whole from a dev point of view. I appreciate the features that the custom Marketo scripts offer, but I hate how heavily-imposed they are.

Why am I forced to use this ill-fitting MktoForms script to do something as simple as retrieve a HTML form and then post data back with an Auth key?

SanfordWhiteman
Level 10
May 4, 2018

There's no obligation to use a visible Marketo form, nor even the Forms JS API, to post data to the Marketo forms endpoint.

You can use a completely bespoke form if you want. Of course, you'd then have to write your own code for validation, progressive profiling, visibility rules, and XHR submission, and the form would not be editable in the Marketo Form Editor (or, to be precise, edits in the Form Editor would have no effect on the public-facing form). But nothing is stopping you from creating a dummy Marketo form and submitting data from another form using its formid (i.e. not even using the Forms JS API to post data, though I don't know why you wouldn't at least take advantage of this part of the library).

What you can't do is scrape the HTML of a form that's intended to be JavaScript-powered and expect it to behave the same way without the JS. This is the same with any JS forms library and isn't specific to Marketo: the HTML does not comprise the core logic.