# How does Web-to-Lead generation work, and what security mechanisms protect against spam?

**Topic:** Sales Cloud · **Difficulty:** Medium · **Tags:** Sales Cloud, Lead Generation, Web-to-Lead

Read it on the site: https://www.forcechallenges.com/interview-questions/how-does-web-to-lead-generation-work-and-what-security-mechanisms-protect-against-spam

## Answer

**Basics:** Marketing sites need to capture inquiries without staff re-typing them. Web-to-Lead produces a form you paste into any website. When a visitor submits, Salesforce creates a Lead, runs assignment and auto-response rules, and can notify the owner.

**How it works:** 1) Setup > Web-to-Lead; enable and set a Default Lead Creator. 2) Click Create Web-to-Lead Form, choose fields and a return URL, optionally tick "Include reCAPTCHA in HTML". 3) Paste the generated HTML on your site. The form posts to `https://webto.salesforce.com/servlet/servlet.WebToLead` with a hidden `oid` (your org ID). 4) Salesforce maps field names (standard API names, custom fields by `00N...` ID) to a new Lead, applies lead assignment rules and auto-response rules, and fires triggers, flows and duplicate rules.

**Advanced / deep dive:** The `oid` is not secret, so anyone can post to your org; spam defense lives with you. Options: Google reCAPTCHA (Salesforce form generator supports it), a hidden honeypot field filtered by a validation rule or flow, validation rules on email and company, duplicate rules, and a middleware or Marketing Cloud Account Engagement (formerly Pardot) form handler for rate limiting. Server-side forms using the REST API with a Connected App avoid exposing a public endpoint but need credential handling. The platform enforces a daily Web-to-Lead cap (commonly documented as 500 per 24 hours); overflow leads are not created and the Default Lead Creator is emailed. Web-to-Case has a separate, higher cap.

**Code / config example:**
```html
<form action="https://webto.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8" method="POST">
  <input type="hidden" name="oid" value="00Dxx0000000000">
  <input type="hidden" name="retURL" value="https://example.com/thanks">
  <input name="first_name" required> <input name="last_name" required>
  <input name="company" required> <input type="email" name="email" required>
  <!-- honeypot: real users leave this empty; filter non-empty values -->
  <input name="description" style="display:none" tabindex="-1" autocomplete="off">
  <input type="submit" value="Submit">
</form>
```

**Hidden gotchas & must-remember points:**
- Spam protection is optional (reCAPTCHA), not automatic.
- The daily cap (about 500 leads per 24 hours) means a spam wave can block real leads.
- Custom fields must use the generated field IDs; renaming does not matter but deleting breaks posts silently.
- No file uploads and no response codes to the browser; errors are invisible to the visitor.
- Required fields are only enforced in the browser unless you add validation rules.
- Picklist values not in the picklist can be rejected or accepted depending on the restricted setting.

**Best practice:** Always add reCAPTCHA plus a validation rule and duplicate rule, and monitor lead volume against the daily limit.

---
Source: ForceChallenges · last updated 2026-11-02
