Create powerful forms for email collection, promo code tracking, and lead capture with ai4shops.com's Form Builder
Forms are the backbone of data collection on your website. With ai4shops.com's Form Builder, you can create forms for newsletters, contact requests, promo code tracking, and more. Connect them to modals for a seamless user experience!
Prerequisites: Make sure you have created a project before starting this guide.
Video Placeholder: Complete Newsletter Form Setup
Duration: 4-5 minutes | Building a newsletter form and connecting it to a modal
Forms in ai4shops.com are powerful data collection tools:
Every form submission automatically captures:
From your project dashboard, click "Forms" in the sidebar.
Screenshot: Forms list page
File: /_static/guides/form-builder/forms-list-en.png
Click the "Create Form" or "New Form" button.
Fill in the basic information:
| Field | Description | Example |
|---|---|---|
| Name | Internal reference name | "Newsletter Signup" |
| Description | Optional notes | "Main website newsletter form" |
Screenshot: Form creation dialog
File: /_static/guides/form-builder/create-form-en.png
Click "Create" to generate your new form. You'll be taken to the form editor.
Build your form by adding and configuring fields.
Screenshot: Form builder with fields
File: /_static/guides/form-builder/form-builder-en.png
| Type | Icon | Best For |
|---|---|---|
| Text | Aa | Names, subjects, general text |
| @ | Email addresses (with validation) | |
| Number | 123 | Quantities, ages, amounts |
| Date | Calendar | Birthdates, appointments |
| Select | Dropdown | Predefined choices |
| Checkbox | Check | Consent, multiple selections |
| Radio | Circle | Single choice from options |
| Textarea | Lines | Long messages, descriptions |
| Phone | Phone | Phone numbers |
| URL | Link | Website addresses |
In the form editor, click "Add Field" or the + button.
Select the field type from the menu.
Set up the field:
| Property | Description |
|---|---|
| Label | Text shown to users |
| Name | Internal identifier (no spaces) |
| Placeholder | Example text inside field |
| Required | Must be filled to submit |
| Validation | Rules (min/max length, pattern) |
| Help Text | Additional guidance |
Screenshot: Field properties panel
File: /_static/guides/form-builder/field-properties-en.png
Drag fields to change their order. Users see fields top to bottom.
| Validation | Available On | Description |
|---|---|---|
| Required | All fields | Field cannot be empty |
| Min Length | Text, Textarea | Minimum characters |
| Max Length | Text, Textarea | Maximum characters |
| Min Value | Number | Minimum number |
| Max Value | Number | Maximum number |
| Pattern | Text, Email | Regex pattern match |
Build an effective newsletter signup form.
Screenshot: Newsletter form setup
File: /_static/guides/form-builder/newsletter-form-en.png
Name it "Newsletter Signup" or similar.
Field Configuration:
emailField Configuration:
firstNameField Configuration:
consentGDPR Compliance: Always include a consent checkbox for newsletter signups in the EU. Store proof of consent with each submission.
Set the message shown after successful submission:
Thank you for subscribing! Check your inbox for a confirmation email.
Track discount code usage and prevent fraud.
Screenshot: Promo code field configuration
File: /_static/guides/form-builder/promo-code-en.png
Create a new form or add to existing checkout form.
Field Configuration:
promoCodeAll submissions automatically include:
| Data Point | What It Tracks |
|---|---|
| IP Address | User location, multiple use detection |
| Device Fingerprint | Unique device identifier |
| User Agent | Browser/device info |
| Timestamp | When code was used |
ai4shops.com helps you identify suspicious activity:
Tip: Export your submissions and analyze patterns to identify abuse. Look for clusters of submissions from the same IP or device fingerprint.
Forms become powerful when connected to modals!
Screenshot: Form-modal connection diagram
File: /_static/guides/form-builder/form-modal-connection-en.png
User fills modal form → submitForm action → Data saved to Form → View in dashboard
Build your form with the fields you need (see above).
Design a modal with input elements matching your form fields.
Important: Modal input name properties must match form field name properties:
| Modal Input Name | Form Field Name |
|---|---|
email | email |
firstName | firstName |
promoCode | promoCode |
On your modal's submit button:
submitForm actioncloseModal action afterNow submissions from your modal are stored in your form and visible in your dashboard!
View and analyze all your collected data.
Screenshot: Submissions table
File: /_static/guides/form-builder/submissions-table-en.png
Navigate to Forms → [Your Form Name].
View the submissions tab to see all collected data.
The table shows:
Click any row to see full submission details including:
Export your data for analysis:
| Format | Best For |
|---|---|
| CSV | Excel, Google Sheets, data analysis |
| JSON | Developers, API integrations |
To export:
| Field | Description | Use Case |
|---|---|---|
| IP Address | Visitor's IP | Geographic insights, fraud detection |
| User Agent | Browser/OS info | Device analytics |
| Device Fingerprint | Unique device ID | Fraud prevention |
| Referrer | Previous page URL | Traffic source analysis |
| Timestamp | Submission time | Timing patterns |
Programmatically submit data to your forms.
POST https://ai4shops.com/api/forms/{form-id}/submit
Include your project API key in the header:
X-API-Key: your-project-api-key
{
"fields": {
"email": "user@example.com",
"firstName": "John",
"promoCode": "SUMMER20"
}
}const submitForm = async (formData) => {
const response = await fetch(
"https://ai4shops.com/api/forms/your-form-id/submit",
{
method: "POST",
headers: {
"Content-Type": "application/json",
"X-API-Key": "your-project-api-key",
},
body: JSON.stringify({
fields: formData,
}),
},
);
if (!response.ok) {
throw new Error("Submission failed");
}
return response.json();
};
// Usage
submitForm({
email: "customer@example.com",
firstName: "Jane",
});import axios from "axios";
const api = axios.create({
baseURL: "https://ai4shops.com/api",
headers: {
"X-API-Key": "your-project-api-key",
},
});
const submitForm = async (formId, data) => {
const response = await api.post(`/forms/${formId}/submit`, {
fields: data,
});
return response.data;
};API submissions are rate limited:
Exceeding limits returns HTTP 429 Too Many Requests. Implement exponential backoff in your code.
Allow your website to submit forms.
Screenshot: Allowed origins settings
File: /_static/guides/form-builder/allowed-origins-en.png
Navigate to Settings → Security or "Allowed Origins".
Enter each domain that will submit to your forms:
https://yourwebsite.com
https://www.yourwebsite.com
https://staging.yourwebsite.com
Click "Save" to apply the new origins.
* in productionWithout correct origins, form submissions from your website will be blocked by CORS policy. Check browser console for CORS errors.
Send submissions to your own server in real-time:
Get notified of new submissions:
Show/hide fields based on answers:
| Error Code | Meaning | Solution |
|---|---|---|
| 401 | Invalid API key | Check your API key |
| 403 | Origin not allowed | Add domain to allowed origins |
| 429 | Rate limited | Wait and retry |
| 400 | Invalid data | Check field names and types |