SOLVED

How to use Forms 2.0 JS API with Drupal form as content type

Go to solution
Vipin_Mp
Level 2

How to use Forms 2.0 JS API with Drupal form as content type

Can anyone know how to submit a lead using Forms 2.0 JS API (on the client side)  to the Marketo database directly, when someone submits Drupal form?

1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: How to use Forms 2.0 JS API with Drupal form as content type

Sample of form markup is

<form action="https://pages.example.com/index.php/leadCapture/save" method="post">
<input type="hidden" data-comment="the numeric form ID" name="formid" value="9999">
<input type="hidden" data-comment="your Munchkin ID" name="munchkinId" value="123-AAA-456">
<input type="hidden" data-comment="the Thank You URL" name="retURL" value="https://www.example.com/thankyou">
<input type="hidden" data-comment="you must fill this with the current document.location.href if you want it logged in Marketo" name="_mktoReferrer" value>
<input type="hidden" data-comment="will be filled automatically with the Marketo cookie value, you need only include the field" name="_mkt_trk">
</form>‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

where pages.example.com is your primary LP domain or a domain alias.

And of course you need to use the Marketo field names.

Don't know why you'd want to do it this way, as it means you need to make your Drupal form look (structurally) exactly like a Marketo form, which isn't very flexible and in some cases might not even be possible. If you want to use a custom form I recommend going fully custom and using the Forms 2.0 JS API method.

View solution in original post

4 REPLIES 4
SanfordWhiteman
Level 10 - Community Moderator

Re: How to use Forms 2.0 JS API with Drupal form as content type

Submit a hidden Forms 2.0 form in the background,  as discussed in many other posts (have you searched?). 

Vipin_Mp
Level 2

Re: How to use Forms 2.0 JS API with Drupal form as content type

Thank you San.. yup.. I have searched and thought like to save the details directly to the database without a hidden form.

SanfordWhiteman
Level 10 - Community Moderator

Re: How to use Forms 2.0 JS API with Drupal form as content type

Sample of form markup is

<form action="https://pages.example.com/index.php/leadCapture/save" method="post">
<input type="hidden" data-comment="the numeric form ID" name="formid" value="9999">
<input type="hidden" data-comment="your Munchkin ID" name="munchkinId" value="123-AAA-456">
<input type="hidden" data-comment="the Thank You URL" name="retURL" value="https://www.example.com/thankyou">
<input type="hidden" data-comment="you must fill this with the current document.location.href if you want it logged in Marketo" name="_mktoReferrer" value>
<input type="hidden" data-comment="will be filled automatically with the Marketo cookie value, you need only include the field" name="_mkt_trk">
</form>‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

where pages.example.com is your primary LP domain or a domain alias.

And of course you need to use the Marketo field names.

Don't know why you'd want to do it this way, as it means you need to make your Drupal form look (structurally) exactly like a Marketo form, which isn't very flexible and in some cases might not even be possible. If you want to use a custom form I recommend going fully custom and using the Forms 2.0 JS API method.

SanfordWhiteman
Level 10 - Community Moderator

Re: How to use Forms 2.0 JS API with Drupal form as content type

Vipin if you're working from the solution above, pls mark my answer as Correct, thanks.