Create Web to Lead form in Salesforce

I decided to write this article because of lots of comments received from the newbies in Salesforce community. We know that the Lead is the pillar object in CRM from where everything is started. And every CRM related software tries their best to offer best and reusable feature to work with lead and same thing is with Salesforce also. In Salesforce you can create a lead by traditional way like logging into application and then performing other steps.

Web-to-Lead in Salesforce
Web-to-Lead in Salesforce

Salesforce also have lots of cool feature to make the life of marketing user easy and one of them is “Web to Lead”. It is possible for any organization that the lead (Potential customer) is coming from the site hosted for some product. So in that case we can host a web form (Simple HTML) on that website and whenever the form is filled its record automatically gets created in Salesforce.

So let’s start walkthrough for creation of “Web to Lead” form.
Navigate to “Settings | App Setup | Customize | Leads | Web-to-Lead”.
Now enable “Web to Lead” setting and assign “Default Lead Creator”, This user will be used to create the lead from Web to lead form.
We can also set the “Default Response Template”, in case we want to auto reply the submitter that his application is submitted successfully.

Web to lead Setting in Salesforce
Web to lead Setting in Salesforce

Then click on button “Create Web-to-Lead Form”.

Generate Web-to-Lead Wizard
Generate Web-to-Lead Wizard

After click on button, above wizard will open.
Here we can decide that which fields should be present in the form and in which sequence.
We can select the return URL (In most of the cases it would be the URL of site from which the form is invoked) also.
Now click on “Generate” button. The HTML code will be generated as per below image.

Web-to-Lead generated code
Web-to-Lead generated code

Copy and Paste the above code in HTML file and place the file as per requirement.
In the generated code, you can edit the CSS as per requirement so that it should look as per the theme of the parent side.

However, do not change the following component in code.

  • “action” url in form tag.
  • “method=post” in form tag.
  • Hidden field value of component name “oid” (This contains the Organization ID and from this only Salesforce comes to know that in which organization the Lead should be created).





Related Posts


9 responses to “Create Web to Lead form in Salesforce”

  1. sudha Avatar

    how to enable assignmentrule for webtolead /webtocase

    1. JitendraZaa Avatar

      Assignment rule automatically gets triggered if condition meets, No extra step required.

  2. ram Avatar

    Dear jitendra,

    Kindly help me out for below issue.[WEB to LEAD]

    Salesforce could not create this lead because of the
    reason listed below. For more information about this error or help with
    Web-to-Case-Lead, please contact Customer Support.

    Reason: Lead Source should be as per the system values

  3. Paresh Avatar

    HI Jitendra, Can you guide me how do I create Web To Lead with Attachments. We have contact us page on website with Attachments and I want to have attachments added to Lead in salesforce.

    1. Jitendra Zaa Avatar

      I can suggest two solutions
      1. Use website and embed that page as an Iframe in your company site OR
      2. Create an email service handler Apex class which accepts attachment. On submit button, internally send attachment to that emailservice address which will relate it to lead. read more here –

      1. Paresh Avatar

        Thanks Jitendra for your prompt response.

  4. Shri Avatar

    Hi Jitendra,

    When creating Web to Lead form I want to add related Campaign. Can you give your inputs.

  5. Deepak Jetty Avatar
    Deepak Jetty

    Is there a way to make this HTML page style with Lightning Page similar? Can we embed this generated code in a Lightning App/Page which can be used outside salesforce and put in Facebook or some social sites? Please help me

  6. Chandramohan Y Avatar
    Chandramohan Y

    Hi Jitendra,
    Please let me know, whether we can embed the web to lead form into any other web pages?


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from Home

Subscribe now to keep reading and get access to the full archive.

Continue Reading

%d bloggers like this: