<form> on an ElasticFunnels page can store its entries in a collection. The builder does this for you when you drag a form onto the page. This page is for when you write the HTML yourself: in the code editor, with the ef CLI, or with an AI agent.
A form needs two things:
- A collection with one field for each input you want to keep.
- A form whose
actionis/api/collection/<code>/store, where<code>is the collection’s code.
With the ef CLI or an AI agent
If you work with theef CLI, the fastest route is to ask your agent. ef init (and ef claude) writes the ElasticFunnels guidance into your project’s CLAUDE.md, and ef codex writes the same into AGENTS.md. That guidance covers forms and collections, so in Claude Code you can say “add a form that collects phone numbers to the landing page” and it creates the collection and writes the markup.
To do it yourself, create the collection first and note the code it prints:
--field is name:type[:required]. Types are text, email, number, checkbox, password, textarea, select and hidden.
Then point the form at it:
Without the CLI
- Go to Pages → Advanced → Collections and click Create Collection.
- Add one field per input, named exactly like the input’s
nameattribute (see the warning above). - Save, and copy the collection’s code.
- Paste the form above into your page’s code, with your code in place of
4k2xqa.
Let ElasticFunnels create the collection
You can also write a plain form with noaction:
action, adds data-collection attributes and inserts success and error message elements. ef push prints the new code and saves the rewritten HTML back into your local file, so open the file again before your next edit.
Two limits:
- It is skipped when the page contains template syntax anywhere (
{{ }},@if,@foreach,@set,@extends). Use the route above for those pages. - Any form with a non-empty
actionthat is not/api/collection/.../storeis left alone. Use that for search boxes or forms that post somewhere else.
data-collection="COLLECTION_CODE" gets the same treatment: COLLECTION_CODE is the placeholder the CLI’s guidance writes, and ef push swaps it for a new collection, with the same two limits.
Full example: a form that collects phone numbers
One phone field and a checkbox that starts unticked. Hidden fields keep the exact wording shown next to the box, the page address and the time the visitor submitted. Tested on a live demo page. Create the collection:0ws38w and your own wording and links:
:required from sms_opt_in and the required attribute from the checkbox.
Saving an entry doesn’t send a text to anyone. On a brand that uses Contacts, the ticked box and the saved wording record an SMS opt-in on the contact (see Email and SMS consent), so campaigns and automations may text that number.
How the form behaves
ElasticFunnels’ page script sends every form whoseaction starts with /api/ and shows the result, without reloading the page.
- Errors. Server errors (“phone is required”, “Your session has expired”) appear in the element with
data-form-error-message. Without one, a red box appears above the submit button. - Success. The element with
data-form-success-messageshows “Thank you for submitting the form.” and the form is cleared. Saving the page resets thedata-success-messageattribute, so for your own wording use theon-form-successevent as in the example. - Redirect. Add
data-redirect-url="/thank-you"to the<form>to send the visitor to another page after a successful entry. - Checks. Required fields, email fields and number fields are checked on the server. Text fields are also screened for random-looking spam text. If the collection has reCAPTCHA v3 turned on, put
<div data-recaptcha-v3="true" data-site-key="YOUR_SITE_KEY"></div>inside the form. - Session. The form only works on pages served by ElasticFunnels. It sends a security token from the page, so a copy of the form on another site is rejected.
Where entries show up
- Collections. Go to Pages → Advanced → Collections and open the collection to see each entry with its fields.
- CRM. Every collection has a matching CRM entity, and each entry is also a record there.
- CLI.
ef collections entries <code>lists the stored entries. - Export. Download entries as CSV, see Export form data.
How an entry links to a visitor
Each entry stores the visitor’s session id and IP address with the fields. The submission also counts as a form-submit event for that visit in your analytics. On a brand that uses Contacts, an entry with an email or phone field also creates or updates that person’s contact and links the visit to it. A form never overwrites a name or address that came from an order; it only fills what the contact is missing. On a brand not yet moved to Contacts, the entry stays a collection record and no contact is made.Tag the contact
Tags on a contact let you start automations and build audiences (“downloaded the ebook in the last 3 days”). A form can tag the contact it creates in two ways.- Always add. Open the collection, find Contact tags and type the tags under Always add. Every entry adds them to the submitter’s contact.
- Tags the page asks for. Add
data-ef-tagsto the<form>, or a hidden field named_tags, with the tags separated by commas. A requested tag is added only when it is listed under Tags a form may request on the collection. Any other tag the page sends is ignored, so a visitor who edits the page can’t give themselves a tag you didn’t allow.
_ . : - (no spaces). A collection holds at most 20 tags in each list. Each tag a contact gains or loses is recorded with its date, so an audience can ask for “tagged ebook in the last 3 days”.
Email and SMS consent
A ticked consent box records an opt-in on the contact only when the form also sends the exact wording the visitor agreed to, in a hiddenconsent_text field (see the phone example above).
- SMS. A checkbox whose name mentions SMS, text or phone together with consent, opt-in, agree or subscribe (for example
sms_opt_in) records an SMS opt-in for the phone number in the form. - Email. A checkbox whose name mentions email, newsletter or marketing together with consent, opt-in, agree or subscribe (for example
email_opt_inorsubscribe_newsletter) records an email opt-in for the email address in the form.
consent_text or a form without that address records nothing. Each opt-in keeps the wording, the page address, the IP address and the browser, and shows on the contact’s record.