Salesforce Web-to-Lead Setup, Best Practices and Common Challenges

Nov 22, 2022

Nothing is better than a seamless integration of a platform’s core functionality. But, for those other times, here are consolidated resources for implementing, maximizing, and troubleshooting the Salesforce useful Web-to-Lead feature.


1. What is Salesforce Web-to-Lead

Web-to-Lead is Salesforce’s out-of-the-box lead management solution for collecting form submissions from your website, and creating lead records directly in your Salesforce Org.

This simple implementation allows you to quickly collect data from visitors to your website; saving time and making your sales representatives work with leads faster.  Automatons like this help maintain a cleaner data base by removing any manual intermediaries that may have potential to alter the data inadvertently.


2. How to Setup Web-to-Lead for your Website

From Salesforce Setup

  • Search Web-to-Lead in the Setup Search Bar and Select Web-to-Lead

  • Edit

  • Click on Web-to-Lead Enabled

  • Save

  • Select Create Web-to-Lead Form

  • Here, select the fields to include within this Web-to-Lead form by using the left and right arrows to move the values to their appropriate side

    • Generated forms are not saved or cannot be referenced as a record within Salesforce.

    • When creating a Web-to-Lead form, you are always created a new form

  • Add your Return URL

    • The Return URL is the page on your site (or any site) that a user is directed to after form submission (Thank You or Confirmation Page)

  • Click Generate

    • The resulting HTML is your new Web-to-Lead form to be provided to the Web Development Team to customize and implement


3. Considerations and Best Practices for Web-to-Lead

Code in Required Fields

The Salesforce generated HTML does not include required or hidden tags on fields. These must be added independently. Adjust the generated HTML with required tags for fields your Salesforce Org requires to create a Lead.

Examples without required field tags

<input id="first_name" maxlength="40" name="first_name" size="20" > <input id="last_name" maxlength="80" name="last_name" size="20" >

Example with Required field tags

<input id="first_name" maxlength="40" name="first_name" size="20" required > <input id="last_name" maxlength="80" name="last_name" size="20" required >


Note: Your coding requirements may differ based on the language of your website.


Utilize Hidden Form Values

With the robust reporting tools of Salesforce, always think ahead to what measured data you want out of this implementation. Ask yourself, what data can this provide now, or in the future.

Along those lines, I recommend adding a hidden field on your Web-to-Lead form that passes a value back to Salesforce. This is incredibly useful to identify Web-to-Lead records against all Lead records.

Example: Create a custom checkbox field isWebToLead with a default value of FALSE. Include this field when generating your HTML. During implementation, adjust the code so this field is hidden from users, but hard-code a value for this field of 1. You now have an easy TRUE/FALSE filter for reporting, Lead Assignment Rules, etc.


Add Google reCAPTCHA

SPAM bots will never surrender their war against website forms. Fortunately, there are a handful of ways to avoid SPAM records from your Web-to-Lead form. The simplest is utilizing the existing functionality Salesforce provides by incorporating Google reCAPTCHA as you generate the HTML in Salesforce.

To include Google reCAPTCHA in your form, include these steps when creating your form.

From the Web-to-Lead Setup page:

  • Select Include reCAPTCHA in HTML

  • Next to reCAPTCHA API Key Pair, click on the Search Icon

  • Select your API Key Pair Nickname

  • Select your intended API Key Pair

  • Select Enable server fallback

    • Server fallback allows all traffic if the Google servers that enable reCAPTCHA are down, so all traffic from your website is captured. Disabling this setting means that traffic from your website won’t be captured when the Google servers are offline.

  • Click Generate


Test thoroughly on your Development Site before pushing Live

It is always recommended to deploy on a testing environment to remove the possibility of business impact. While setting up the Web-to-Lead seems simple, there are many variables on a website that can impact the form functionality. Test extensively before deploying.


4. Common Challenges Web-to-Lead

During implementing and testing, there are a handful of common challenges that may arise. Here are the most common, and their resolutions.

Challenge 1 – Web-to-Lead forms being submitted without reCAPTCHA

When you include reCAPTCHA when generating your form through Salesforce, the HTML does not include any submission restrictions or validations. While the reCAPTCHA is present, a user (or bot) can still submit the form regardless.

To resolve, implement a code adjustment that does not allow the submit button to be active until the reCAPTCHA has been completed.

Here is a great article that walks through restricting submission until reCAPTCHA is verified with JavaScript (towards the bottom of the article).


Challenge 2 – Users are not directed to the Return URL after Submission

If after submission, you are not redirected to your return URL, check the following.

Review the code to confirm that the retURL value has not been removed or manipulated when placing it on the website. If your return value is dynamically generated due to the layout of your site, confirm that the reference value is configured correctly.

<input type=hidden name="retURL" value="https://oswdigital.com/">

If there are no apparent issues in the underlying code, and you have reCAPTCHA enabled, navigate to the reCAPTCHA Admin where you created your Site Key and Secret. Confirm that on submission, the reCAPTCHA is being hit. On that page you will see Total Verification showing the number of successful verification that have hit that reCAPTCHA. If the reCAPTCHA is not being hit, you may need to look at reCAPTCHA placement in your code to see if it is being blocked.


5. Web-to-Lead reCAPTCHA Alternatives

In the event Google reCAPTCHA is not an option, or there are continued challenges with implementation, you can handle SPAM through Salesforce.

One simple way to do this is create honeypot fields on your forms. This involves creating a custom Salesforce field (your honeypot), and hiding that field on your website form page so that users cannot see it, but a bot will. Once implemented, you can use Lead Assignment rules to assign Leads when these values are not empty, and direct them into a special SPAM queue. Once in that SPAM queue, you can delete or process how you see fit. Remember:

  • The field must look like a legitimate field, such as EmailAddress or PhoneNumber, otherwise the bots may catch-on

  • Hide these fields from your Org users to avoid confusion – remember, these are fields not to be used by users, but purely to help weed out SPAM

Here is a great article on implementing a strong honeypot on your website for any type of form.


6. Web-to-Lead Salesforce Resources

There are many great resources on Web-to-Lead. Please use the collected links below to help further your Salesforce knowledge and share with others.

Google reCAPTCHA Setup

Get Started: Building Web Forms (YouTube)

Guidelines for Setting Up Web-to-Lead

Web-to-Lead in Salesforce

What is web to lead? (Developer)


Thank you for reading. If you have any recommendations or suggestions to add, please comment below!