I've integrated the web-to-lead code (created from the salesforce ui) into a popup on a wordpress website.

My ideal flow is as follows:

  1. User opens the popup and fills in the web-to-lead form.
  2. User presses submit and a new lead gets created on the associated salesforce account.
  3. On the same popup, the user receives a success message.
  4. User will close the popup and continue on his merry way.

What's actually happening:

  • After the user presses the submit button, the page redirect occurs. Even if the url is the same url he/she is currently on, the page will refresh and the popup closes automatically. There's no chance for the success message to be displayed.

My code:

<form action="https://webto.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8" method="POST" target="_self">
  <input type=hidden name="oid" value="XXXXXXXXXXXX">
  <label for="first_name">First Name</label><input id="first_name" maxlength="40" name="first_name" size="20" type="text" /><br>
  <label for="last_name">Last Name</label><input id="last_name" maxlength="80" name="last_name" size="20" type="text" /><br>
  <label for="email">Email</label><input id="email" maxlength="80" name="email" size="20" type="text" /><br>
  <label for="company">Company</label><input id="company" maxlength="40" name="company" size="20" type="text" /><br>
  <label for="phone">Phone</label><input id="phone" maxlength="40" name="phone" size="20" type="text" /><br>
  <input type="submit" name="submit">

Originally, I also had <input type=hidden name="retURL" value="https://mywebsite"> . However I removed it in hopes that the redirect wouldn't occur. Sadly, the redirect still occured.

  • Please do not create duplicate accounts. You just tried to edit this post with an entirely new account, rather than logging in to your original account.
    – Adrian Larson
    Sep 13, 2017 at 20:41

2 Answers 2


The reason it is behaving as it is because web-to-lead code is embedded into the page source (as in inlined with main page source). Since that form is submitted, browser is going to treat as main page submission.

You can do two things.

  1. Change the return url in Salesforce config to include a variable. For ex., https://www.example.com/contact?success=true. Then in the on page load, if that variable is there, then show the thank you or success message.

  2. Load the web to lead in popup with iframe. Then when submission happens, iframe is submitted. Then you can display a message to user.


You could try submitting the form with javascript but block the page refresh. This might be a good pointer for you: https://stackoverflow.com/questions/23507608/form-submission-without-page-refresh

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .