Phase 6 part 3: website lead forms into EspoCRM
Sites → Lead forms sets up the site's forms to create EspoCRM Leads through its Lead Capture: the address saved and tested with a CORS preflight, and a pull request adding a script that maps the form's fields onto a Lead (campaign, page and form in the description). Plausible's Lead goal is imported per signal as interested. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1424,6 +1424,37 @@ secrets.json too (the old one kept in the backups folder), while this
|
||||
machine's mcp-token stays. Tried live both ways (the command line and the
|
||||
page) by restoring a backup taken seconds before.
|
||||
|
||||
**Part 3 built (2026-11-22; no schema change).** EspoCRM's Lead Capture
|
||||
(docs: docs.espocrm.com/administration/web-to-lead/) takes a JSON `POST
|
||||
<crm>/api/v1/LeadCapture/<api key>` without a login, allows other sites
|
||||
by default (`leadCaptureAllowOrigin`, "*"), and has one fixed Campaign per
|
||||
Lead Capture: a per-submission campaign can't be passed. So the signal
|
||||
travels in the Lead's description, and Plausible counts it. Sites → Lead
|
||||
forms:
|
||||
- shows how the site's forms post now (`[params.leads] action`), which
|
||||
pages have a form, and whether this site's form section can be
|
||||
connected;
|
||||
- gives the EspoCRM steps (a Lead Capture whose Payload Fields are First
|
||||
Name, Last Name, Email, Account Name, Phone, Description);
|
||||
- saves its API URL (checked: https, `/api/v1/LeadCapture/<key>`) and
|
||||
tests it with a CORS preflight from the site's origin (nothing created);
|
||||
- opens a pull request (`supermarket/lead-forms`): `[params.leads]
|
||||
action` in `hugo.toml`, `static/js/supermarket-leads.js` defining
|
||||
`window.leadPost(form, data)`, and the form partial loading it and
|
||||
calling it in place of its own `fetch(form.action, …)` (patched only if
|
||||
that call is there; matched on federated-website's). The script maps
|
||||
name (split), email, organization/company, phone onto the Lead; the
|
||||
form's name, other answers (by label), the page, the visit's UTM tags
|
||||
and the referrer go in the description. Checked with a build: a page
|
||||
with a form loads the script and posts to the Lead Capture.
|
||||
- counts form leads: the forms already send Plausible a `Lead` event, so
|
||||
the daily Plausible import also reads the `Lead` goal by the visit's
|
||||
UTM tags and records them as *interested* on the signal's funnel (or
|
||||
says to add the goal in Plausible).
|
||||
Tested with Node running the script on a form's data. Not done for real:
|
||||
creating the Lead Capture in EspoCRM, and the pull request on the real
|
||||
site.
|
||||
|
||||
### Future enhancements
|
||||
|
||||
Not in any phase yet; picked up when the user asks.
|
||||
|
||||
Reference in New Issue
Block a user