SOLVED

Using reCAPTCHA with background submission

Go to solution
Kevin_Vaughn
Level 2

Using reCAPTCHA with background submission

We have an existing form that has been running for some time. We would like the lead and a subset of the information to be captured in Marketo as well. So, we set up a background or parallel submission with a Marketo form – which is working fine. We would also like to enable recaptcha for the Marketo form, as all of our processes trigger off of successfully passing recaptcha. 

 

The issue comes in when I enable recaptcha on the Marketo form. As soon as I enable recaptcha the background submission stops working. When I disable the recaptcha it begins working again. Does anyone know if it is possible to use recaptcha with a parallel submission?

1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: Using reCAPTCHA with background submission

You’ve implemented this incorrectly.

There’s a quite obvious race condition that makes the hidden Marketo form post unreliable even without reCAPTCHA — it’s merely more prominent because the extra step of reCAPTCHA token generation makes the Marketo form post take more time (another turn of the JS event loop).

 

Upon the standard HTML form’s submit event, you need to preventDefault()and submit the Marketo form instead. In the Marketo form’s onSuccess(), you re-submit the HTML form, this time letting it go through.

 

Your current code (below) doesn’t wait for the Marketo form to submit. The 2 forms are in a race — which the HTML form will win whenever Salesforce Web2Lead responds faster:

 

<script type="text/javascript"> 
  function ValidateForm(thisForm, submitMktoForm) {
    submitMktoForm();
  }
</script>

<form id="order_resources" action="https://webto.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8" method="post">
<!-- ... other form fields... -->
<button type="submit" name="submit" id="submit" onclick="return ValidateForm(this, submitMktoForm)">Submit</button>
</form>

 

 

 

View solution in original post

6 REPLIES 6
SanfordWhiteman
Level 10 - Community Moderator

Re: Using reCAPTCHA with background submission

Does your background form have Known Visitor HTML enabled? Do you have a page we can look at?
Kevin_Vaughn
Level 2

Re: Using reCAPTCHA with background submission

Hi Sanford.

Thanks for your quick response. 

The form does not have Known Visitor HTML enabled. Here is a link to the page, https://www.fffenterprises.com/resources/mkto-background-submission.html 

SanfordWhiteman
Level 10 - Community Moderator

Re: Using reCAPTCHA with background submission

That form doesn’t have reCAPTCHA enabled.

Kevin_Vaughn
Level 2

Re: Using reCAPTCHA with background submission

Thanks for your response. Yes, that is correct. I disabled it because the submission stops working with it enabled. I have reenabled it (please see below).

Here's a  page with everything stripped out but the essentials, https://www.fffenterprises.com/resources/mkto-background-submission.html

 

Kevin_Vaughn_0-1682698601437.png

 

SanfordWhiteman
Level 10 - Community Moderator

Re: Using reCAPTCHA with background submission

You’ve implemented this incorrectly.

There’s a quite obvious race condition that makes the hidden Marketo form post unreliable even without reCAPTCHA — it’s merely more prominent because the extra step of reCAPTCHA token generation makes the Marketo form post take more time (another turn of the JS event loop).

 

Upon the standard HTML form’s submit event, you need to preventDefault()and submit the Marketo form instead. In the Marketo form’s onSuccess(), you re-submit the HTML form, this time letting it go through.

 

Your current code (below) doesn’t wait for the Marketo form to submit. The 2 forms are in a race — which the HTML form will win whenever Salesforce Web2Lead responds faster:

 

<script type="text/javascript"> 
  function ValidateForm(thisForm, submitMktoForm) {
    submitMktoForm();
  }
</script>

<form id="order_resources" action="https://webto.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8" method="post">
<!-- ... other form fields... -->
<button type="submit" name="submit" id="submit" onclick="return ValidateForm(this, submitMktoForm)">Submit</button>
</form>

 

 

 

Kevin_Vaughn
Level 2

Re: Using reCAPTCHA with background submission

My apologies for the slow response. I was out of the office. 

 

Thank you for the assistance. This makes complete sense. Much appreciated.