Embedding form on website without form tag

Hayley_Iacocca
Level 2

Embedding form on website without form tag

We want to embed a Marketo form on a page of our website. When we provided the form embed code, our developers shared that our website already has the asp form tag on the page. Since the Marketo embed code also has a form tag in it, it won't work on our webpage. Does any know of any other options, that doesn't include a form tag, for embedding a Marketo form (e.g. javascript)?


14 REPLIES 14
SanfordWhiteman
Level 10 - Community Moderator

Re: Embedding form on website without form tag

The embed code only includes the <form> tag for convenience. As long as your <form> has the id="mktoForm_nnn" it will work just as well, just remove the <form> from the embed code.

Hayley_Iacocca
Level 2

Re: Embedding form on website without form tag

Thanks for this recommendation, Sanford. I just checked with our developer but she said it won't work. She said the solution still depends on having the form tag on the page and we can't add the id="mktoForm_nnn" to our existing form tag.

SanfordWhiteman
Level 10 - Community Moderator

Re: Embedding form on website without form tag

You have to add the id to the form, at least temporarily. Marketo forms do not directly take an HTMLFormElement as an argument.

I don't understand a situation in which you must use an existing form element but cannot add any attributes.

Hayley_Iacocca
Level 2

Re: Embedding form on website without form tag

We cannot change the form tag on the webpage because it’s a template that’s used across our entire website. Our website uses an ASPX form page (view-source:https://www.cooperators.ca/en.aspx), and we can’t have a form within a form. So we’re trying to see if there’s another option or a workaround that allows for the same functionality (i.e. individual enters their information which then feeds into our Marketo database), without actually using a form.

SanfordWhiteman
Level 10 - Community Moderator

Re: Embedding form on website without form tag

An option on the client side is to make a hidden Marketo form post in the background, supplying the values from your non-Marketo form. This has been discussed here in the past, if you search the Nation. This blog post has a basic example.

This is the only scalable, reliable alternative to a Marketo form.

Arun_Sharma9
Level 4

Re: Embedding form on website without form tag

I think the best approach should be hide the current <form> tag on your website using CSS rules by using the class or id element present on that particular form but making sure the CSS is affecting that form on the page you wanted to load the Marketo form.

Then you can just use the Marketo embed code on the page where you want to show the form.

If above also don't work, then you can remove the <form> element from the page by using SetTimeout function of JavaScript after page is loaded and then load the Marketo form after that timeout, this will allow any other <form> element to get removed from page and loading of Marketo form.

Furthermore, If you can provide link to the page where you wanted to embed Marketo form, any other solution can also be provided.

Solution provided by Sanford will also work.

Arun Sharma
SanfordWhiteman
Level 10 - Community Moderator

Re: Embedding form on website without form tag

Hayley specifically and repeatedly stated that the developer refused to remove the existing form. If the developer were willing to do what you describe, they would've already done it.

(And setTimeout should never be used for DOM timing. Use the events provided by the browser API (DOMContentLoaded) for elements included in the HTML response, or the events provided by a specific library API (such as the whenReady event of the Forms 2.0 API) for elements injected asynchronously. Countless sites are horribly broken by misuse of setTimeout to guess (and guess wrong!) when elements or objects are ready.)

Bryan_Epstein
Level 6

Re: Embedding form on website without form tag

Hayley, this is something that had worked where we did utilize a hidden form to guide submissions to the Marketo database. This was at the last company I worked at. The blog post Sandy references points to the following page on the Marketo documentation.

Sanford Whiteman​, one of the issues that we had run into was that individuals were feeding into SFDC as leads through our lifecycle model. As a means to prevent this from happening in Hayley's instance, would she just have to add a filter [Filled Out Form is NOT Hidden Form]?

SanfordWhiteman
Level 10 - Community Moderator

Re: Embedding form on website without form tag

..individuals were feeding into SFDC as leads through our lifecycle model. As a means to prevent this from happening in Hayley's instance, would she just have to add a filter [Filled Out Form is NOT Hidden Form]?

Sure, if this form is an outlier and not meant to send leads through a typical flow you can constrain Filled Out Form on the form name.