SOLVED

Marketo form and AJAX!

Go to solution
Anonymous
Not applicable

Marketo form and AJAX!

I am using a Markto form to collect lead information. After the lead finishes filling out the form and hits submit, I would like for a download button to appear under said form without the page refreshing or being re-directed to a thank-you landing page. Has anyone ever used AJAX with a non-Marketo landing page form or, found a way to achieve what I am asking above through some other custom form code/script?

Any direction to additional resources would be greatly appreciated

Thanks!
Tags (1)
1 ACCEPTED SOLUTION

Accepted Solutions
Anonymous
Not applicable

Re: Marketo form and AJAX!

One other article on community which can help is
http://community.marketo.com/MarketoResource?id=kA650000000GsXXCA0
This page explains how to submit a Marketo form.
 
The following page explains javascript related details about how to submit to a generic form.
http://net.tutsplus.com/tutorials/javascript-ajax/submit-a-form-without-page-refresh-using-jquery/

You can have an AJAX call and http post a Marketo form when the submit button is pressed by utilizing the above information.

This is an alternative to SOAP and PHP for your requirement. Though, you can certainly do it that way.

Hope this helps.

Rajesh
 

View solution in original post

9 REPLIES 9
Anonymous
Not applicable

Re: Marketo form and AJAX!

Hi Robert,

There can be multiple ways to achieve this. WIth varied degree of complexity. From AJAX to API and server based HTTP post etc. But here might be a simpler solution. Hope this works for you.

One way might be to have a non-marketo page as your landing page. This page will have among others, a Marketo form in an iFrame. This Marketo form will be a barebone form with just the fields you want to be shown. No text etc. Configure the thank you page of this Marketo form to be the 'download' button you want to display.

Thus when the user comes to your page, he/she will see the form. When he/she submits the form (in iframe), (only) the iframe content will refresh to show the download button. 

No complex AJAX needed. Though I have used AJAX many times, I prefer to opt for low-maintanance, easy to implement and duplicatable solutions.

Hope this helps....

Rajesh
Calvin_Lam
Level 4

Re: Marketo form and AJAX!

I like Rajesh's solution.  It is easier to do, maintain and test.  Just in case that the form does take a long time to process for whatever reason, couple things to consider are
  • Hide the iframe completely while the form is processing
  • Display some icon to indicate that the form is processing until the post back is fully completed
If you really want to do an AJAX style background form post-back, it is probably best to create a Non-Marketo landing page with your own form.  Then use the SOAP based or Munchkin API to make calls to Marketo in the background once the Submit button is pressed.


Anonymous
Not applicable

Re: Marketo form and AJAX!

Howdy Rajesh and Calvin!

First off, thanks for the super quick replies last week. You both are providing me with some great approaches! 

Rajesh -  I really wish it was that easy for me to go the with the iFrame. However,  I am using some php switches within my form to serve up specific hidden fields based on what page the user is on. We provide multiple "plans" to sign-up for and I have to pass within the hidden field what option this lead is coming from. Instead of creating a form for each plan I am using one dynamic form that will take care of everything. The less repition of code the better :-).  I basically want to POST all the information from the form to the Marketo database. 

Calvin - I already setup the form in Marketo...is there a way to still use this? I feel like I can strip away some of the code that makes it Marketo specific. I am thinking I will need to get rid of the submit and then create a button which will bind to the ajax call.

Thanks again for all your advice guys! Seems like checking out the SOAP API is my best bet. If any of you have had experience developing what I am describing above, it would be great to get your advice on the best way so send my data off.

-Rob
Anonymous
Not applicable

Re: Marketo form and AJAX!

I actually just found this article that seems to talk about what I am trying to accomplish!

http://ahmeddirie.com/technology/web-development/marketos-updated-soap-php-client-and-the-new-way-to...
Anonymous
Not applicable

Re: Marketo form and AJAX!

One other article on community which can help is
http://community.marketo.com/MarketoResource?id=kA650000000GsXXCA0
This page explains how to submit a Marketo form.
 
The following page explains javascript related details about how to submit to a generic form.
http://net.tutsplus.com/tutorials/javascript-ajax/submit-a-form-without-page-refresh-using-jquery/

You can have an AJAX call and http post a Marketo form when the submit button is pressed by utilizing the above information.

This is an alternative to SOAP and PHP for your requirement. Though, you can certainly do it that way.

Hope this helps.

Rajesh
 
Anonymous
Not applicable

Re: Marketo form and AJAX!

One other article on community which can help is
http://community.marketo.com/MarketoResource?id=kA650000000GsXXCA0
This page explains how to submit a Marketo form.
 
The following page explains javascript related details about how to submit to a generic form.
http://net.tutsplus.com/tutorials/javascript-ajax/submit-a-form-without-page-refresh-using-jquery/

You can have an AJAX call and http post a Marketo form when the submit button is pressed by utilizing the above information.

This is an alternative to SOAP and PHP for your requirement. Though, you can certainly do it that way.

Hope this helps.

Rajesh
Anonymous
Not applicable

Re: Marketo form and AJAX!

Rajesh! I would like to thank you for your help with my issue! The resources you provided me were  super valuable and I have successfully been able to transfer data to marketo from my form! (Wooo!)

I am having an issue with the ajax I am using. I am wondering if you have any suggestions or have had any experience with my problem? Whenever I POST data to Marketo I get a 302 ( from the documentation this is  to be expected). Because of this I am not able to get a success to fire on my ajax.

This is probably not the form to talk code. If you have any suggestions feel free to join the thread here: http://stackoverflow.com/questions/19676086/ajax-success-with-expected-302-redirect 
Anonymous
Not applicable

Re: Marketo form and AJAX!

I think that it's the browser's Ajax implementation that is handling the redirect. if this is the case, jQuery has no power to make it act otherwise.
 
A redirect (302) for your AJAX request is likely to be handled automatically by the browser and response of the redirect is handled over to the the AJAX call. Can you check for AJAX status as 200 and treat it as success?

Rajesh
 
Anonymous
Not applicable

Re: Marketo form and AJAX!

Hey Rajesh,

I am actually using wordpress and needed to handle the response a bit differently. Basically, because I was pushing data server to server, I needed to create a function that would push the code from the back end and not from the client-side. I just don't think there is another way to do it, especially with the domain origin policy. So all is working now and I am even getting a 200 response.

My only issue now is to find out what the error response marketo throws on their side.The responseText I get now is "<html><head><meta http-equiv="refresh"  content="0; url=http://xxx-xxx.marketo.com/"></head></html>"  but that is on success. Would be good to know what an error throws so I can actually make sure their server was successfully pinged and serve up an error message to the user if not.

Calvin, you might be able to answer this one!