Form Submit Event
Track when users submit forms on your site. This event maps to Facebook Lead
and TikTok SubmitForm standard events, enabling lead generation tracking,
form conversion analysis, and ad optimization for lead campaigns.
When to Use This Event
The form.submit event should be triggered when a user successfully submits a form.
This typically occurs when:
- User submits a contact form
- User submits a lead generation form
- User fills out a quote request form
- User submits any form that captures email or contact information
| Platform | Event Name | Optimization |
|---|---|---|
| Facebook Pixel / CAPI | Lead |
Optimizes for lead generation campaigns |
| TikTok Pixel / Events API | SubmitForm |
Optimizes for form completion campaigns |
Use form.submit for general forms (contact, quote request, feedback).
Use the Subscribe event specifically for newsletter/mailing list signups
- it maps to Facebook/TikTok Subscribe and provides dedicated subscription tracking.
SDK Loading
Load the AxiTrace SDK synchronously in your <head> before any tracking calls:
<!-- In <head> -->
<script src="https://stat.axitrace.com/axitrack.js"></script>
<script>
Axitrace.init({
publicKey: 'pk_live_YOUR_PUBLIC_KEY'
});
</script>
Client-Side vs Server-Side Tracking
For each form submission, use either the JavaScript SDK or the server-side API - not both.
The JavaScript SDK automatically fires Facebook (Lead) and TikTok (SubmitForm)
pixels with a matching eventID, then sends the event to the AxiTrace backend which forwards
it to CAPI. Facebook/TikTok deduplicates using the shared eventID, counting one event.
If you also send the same event via the server-side PHP SDK, it generates a different
eventID - causing Facebook/TikTok to count the event twice.
Recommendation: For lead forms, server-side tracking is often preferred
because: (1) it ensures the event is captured even if the page redirects after submission,
(2) it has access to server-validated form data, and (3) the PHP SDK auto-reads cookies for
proper user profile linking. If you use server-side tracking, do not also call
Axitrace._instance.track('form.submit', ...) in the browser for the same form submission.
Request Parameters
Client Identification
The client object must contain at least one identifier:
| Field | Type | Description |
|---|---|---|
client.customId |
string | Your custom visitor identifier (use SDK's vt_vid cookie value) |
client.id |
integer | Numeric user ID from your system |
client.uuid |
string | UUID identifier for the user |
client.email |
string | User's email address (improves Facebook CAPI match quality) |
client.phone |
string | User's phone number (improves Facebook CAPI match quality) |
For server-side events, you must pass the same user identifiers that the JavaScript SDK generates. The SDK stores these in cookies:
vt_vid- Visitor ID (persistent anonymous identifier → use asclient.customId)vt_sid- Session ID (current browsing session → use assessionId)vt_uid- User ID (set viaidentify()→ use asclient.customId)
Read these cookies and pass them in your server-side events to properly link all events to the same user profile. See the User Identification guide for complete details.
Required Fields
| Field | Type | Description |
|---|---|---|
label |
string |
Form identifier/name (e.g., "contact-form", "newsletter-signup", "quote-request").
Required, must be non-empty. The JavaScript SDK auto-fills this
from the page title - you don't need to set it manually when using track().
|
params |
object | Form data and additional parameters. Required, must be a non-empty object. |
Optional Fields
| Field | Type | Description |
|---|---|---|
sessionId |
string | Current session identifier. The JavaScript SDK auto-fills this from the vt_sid cookie. |
time |
ISO 8601 | Custom event timestamp. If not provided or in the future, server time is used. |
eventSalt |
string | Unique event ID for deduplication. The SDK auto-generates a UUID for each track() call - this same ID is passed to Facebook/TikTok pixels for pixel-CAPI deduplication. |
value |
number | Optional lead value, zero or more (for example the quoted amount). Context for Leads, never revenue. |
currency |
string | ISO 4217 code of value and of the product prices, for example EUR. |
products |
array | Optional products the lead is about, in the transaction line shape. An invalid line is dropped and the lead is still stored. See Rules for lead products. |
Params Object
The params object contains form data and customer information:
| Field | Type | Description |
|---|---|---|
email |
string | Email address from the form. Validated if provided - must be a valid email format. |
phone |
string | Phone number (E.164 format recommended). Sent as plain text - AxiTrace auto-hashes for Facebook. |
first_name |
string | User's first name. Sent as plain text - AxiTrace auto-hashes for Facebook. |
last_name |
string | User's last name. Sent as plain text - AxiTrace auto-hashes for Facebook. |
company |
string | Company name (for B2B lead forms) |
message |
string | Message or comments from the form |
Customer Data (for Facebook CAPI)
Include these fields in the params object to enhance Facebook Conversions API matching:
| Field | Type | Description |
|---|---|---|
city |
string | City name |
state |
string | State or province |
zip |
string | ZIP or postal code |
country |
string | Country code (ISO 3166-1 alpha-2) |
fbp |
string | Facebook Pixel browser ID (from _fbp cookie) |
fbc |
string | Facebook Click ID (from _fbc cookie) |
Send all customer data (email, phone, first_name, last_name, etc.) as plain text. AxiTrace passes these values to the Facebook PHP SDK, which automatically normalizes and SHA-256 hashes them before sending to CAPI. Pre-hashing will cause double-hashing and break Facebook's matching.
Pixel Deduplication
When using the JavaScript SDK, form.submit events are automatically deduplicated
between browser pixels and server-side CAPI:
- SDK generates a unique
eventSalt(UUID) for eachtrack()call - SDK fires
fbq('track', 'Lead', params, {eventID: eventSalt})in the browser - SDK fires
ttq.track('SubmitForm', params, {event_id: eventSalt})in the browser - SDK sends the event (with the same
eventSalt) to the AxiTrace backend - Backend forwards the event to Facebook CAPI and TikTok Events API with the same
eventSaltas the event ID - Facebook/TikTok matches the pixel event and CAPI event by
eventIDand counts it once
This happens automatically - you don't need to manage event IDs manually.
How form submissions are classified
The JavaScript SDK fires form.submit for every form a visitor submits - the
search box, the login form, each checkout step and the contact form all arrive under the same event name.
Before forwarding, AxiTrace looks at the form's id, name, label, action
and the page URL and decides what the submission really is:
| Detected form | Typical signals | What is forwarded |
|---|---|---|
| Account sign-up | register, signup, create-account, /register … |
complete_registration - Meta CompleteRegistration, TikTok CompleteRegistration, Reddit & LinkedIn SIGN_UP, GA4 sign_up, OpenAI registration_completed |
| Login | login, signin, login_check, /login … |
Nothing - an existing customer signing in is not a conversion |
| Search box | search in the form name or action |
Nothing - the dedicated search event already covers it |
| Checkout step | checkout, shipping, payment, /order/, /cart … |
Nothing - begin_checkout, add_payment_info and the purchase already describe the buyer |
| Account or system form | password, forgot, resend, verify, check your email, accept invitation, /reset-password, /team/accept, /install/resume, a password field … |
Nothing - a password reset, an e-mail verification, a two-factor code or an invitation is your site working, not a visitor converting |
| Everything else (contact, quote, newsletter …) | No match above | form.submit as today - Meta Lead, TikTok SubmitForm, Reddit & LinkedIn LEAD, GA4 generate_lead, OpenAI lead_created |
Only submissions that captured an email address are forwarded at all; the rest are still stored
in AxiTrace for reporting. SDK 0.9.1 and newer applies the same rules in the browser, so the Meta / TikTok /
Pinterest pixel calls and the server-side events always carry the same event name and deduplicate correctly.
To steer the automatic detection, set data-velitrack-label on the form - for example
data-velitrack-label="register" on a sign-up form whose id is generic. To skip the
detection altogether, declare the form type yourself (below).
Declaring the form type yourself
The detection above is a guess made from names and URLs. When you know what a form is, say so: a declared type is final - AxiTrace never re-classifies it, in the browser or on the server. These are the types AxiTrace supports:
| Type | Meaning | Lead in Leads | Forwarded to ad platforms as |
|---|---|---|---|
lead | A contact, quote, inquiry or newsletter form | Yes (inquiry; subscription for a newsletter-named form) | form.submit (Meta Lead, GA4 generate_lead …) |
registration | A new customer account was created | Yes (registration) | complete_registration |
login | An existing customer signed in | No | Nothing |
search | A search box | No | Nothing |
checkout_step | A step of the cart or checkout (address, delivery, notes) | No | Nothing |
system | An account or app flow: password reset, e-mail verification, two-factor code, invitation accept, app install, a tool's own input box | No | Nothing |
On the form (JavaScript SDK auto-capture): add data-axitrace-form-kind with one
of the types. An unknown value is ignored and the form is detected as usual.
<form action="/account/password/reset" data-axitrace-form-kind="system">...</form>
<form id="step-2" data-axitrace-form-kind="registration">...</form>
From your own JavaScript: pass formKind to track(). A kind passed
this way is a declared one.
Axitrace._instance.track('form.submit', {
label: 'quote-request',
email: 'jane@example.com',
formKind: 'lead'
});
PHP SDK and HTTP API: send formKind together with
formKindSource: "declared" in the params. A formKind without
formKindSource is treated as detected, and a detected lead on a password,
verification or invitation form is still corrected to system.
<?php
$axitrace->formSubmit('quote-request', ['email' => $_POST['email']], [
'formKind' => 'lead',
'formKindSource' => 'declared',
]);
A form whose lead your server records
When your server already records the lead for a form - for example it sends a
start trial once the account
exists - the browser's submit of that form would be a second lead for the same person. Mark the form with
data-axitrace-no-lead (or pass noLead: true to track(), the PHP SDK
or the HTTP API params). The submission keeps its type, so the ad platforms still receive it (a sign-up is
still CompleteRegistration), but Leads does not store it.
<form id="signup" data-axitrace-form-kind="registration" data-axitrace-no-lead>...</form>
Sending leads to Google Ads
Google Ads receives form leads only when you ask for them. In your Google Ads connection settings, tick
Lead (form submission) and pick the conversion action it uploads to. That covers submissions
from the AxiTrace form listener and generate_lead events read from your dataLayer. Create that
action in Google Ads with the category Submit lead form; a lead is never uploaded to your
purchase conversion action. As above, a lead is sent only when the form captured an email address, and
Google Ads matches it through the visitor's click ID or that email or phone.
Products and Value (Leads)
A form submit can carry the products the inquiry is about and a value, as root products,
value and currency. Both are optional, appear on the lead in
Leads and are never counted as revenue. An invalid product line is
dropped; the form submit is always stored. Calls without these fields work exactly as before.
<?php
// PHP SDK 1.12.0 or later
$event = (new FormSubmitEvent('quote-request'))
->setClientEmail($_POST['email'])
->setFormParams(['email' => $_POST['email']])
->setValue(1200.00, 'EUR')
->addProduct(['sku' => 'SOFA-3', 'name' => 'Three-seat sofa', 'finalUnitPrice' => 1200.00, 'quantity' => 1]);
$axitrace->track($event);
// or through the helper's $params
$axitrace->formSubmit('quote-request', ['email' => $_POST['email']], [
'value' => 1200.00,
'currency' => 'EUR',
'products' => [['sku' => 'SOFA-3', 'name' => 'Three-seat sofa', 'finalUnitPrice' => 1200.00, 'quantity' => 1]],
]);
Axitrace._instance.track('form.submit', {
label: 'quote-request',
email: 'jane@example.com',
value: 1200,
currency: 'EUR',
products: [{ sku: 'SOFA-3', name: 'Three-seat sofa', finalUnitPrice: 1200, quantity: 1 }]
});
The full rules, the HTTP API body and the dataLayer generate_lead mapping are on the
Leads page.
Server-Enriched Fields
The following fields are automatically added by the server:
| Field | Description |
|---|---|
ip |
Client IP address (extracted from X-Forwarded-For, CF-Connecting-IP, etc.) |
userAgent |
Browser User-Agent string |
timestamp |
Server timestamp (ISO 8601 format) |
Examples
JavaScript SDK (Recommended for Client-Side Forms)
// Basic form submit tracking
document.querySelector('#contact-form').addEventListener('submit', function(e) {
const formData = new FormData(e.target);
// Track form submit - fires Facebook Lead + TikTok SubmitForm pixels automatically
Axitrace._instance.track('form.submit', {
label: 'contact-form',
email: formData.get('email'),
first_name: formData.get('firstName'),
last_name: formData.get('lastName'),
phone: formData.get('phone'),
message: formData.get('message')
});
});
// Lead generation form with full details
Axitrace._instance.track('form.submit', {
label: 'quote-request',
email: 'prospect@company.com',
first_name: 'John',
last_name: 'Doe',
phone: '+1-555-123-4567',
company: 'Acme Corp',
message: 'I need a quote for enterprise plan'
});
Server-Side (AxiTrace PHP SDK)
<?php
use AxiTrace\AxiTrace;
// Initialize - auto-reads vt_vid, vt_sid, _fbp, _fbc cookies
// Also auto-detects client IP, user-agent, and attribution params (fbclid, utm_*)
$axitrace = AxiTrace::init('sk_live_YOUR_SECRET_KEY');
// Get form data from POST request
$email = $_POST['email'] ?? '';
$firstName = $_POST['first_name'] ?? '';
$lastName = $_POST['last_name'] ?? '';
// Process your form (save to DB, send email, etc.)
// ...
// Track to AxiTrace - cookies, IP, user-agent, and attribution are handled automatically
$response = $axitrace->formSubmit('contact-form', [
'email' => $email,
'first_name' => $firstName,
'last_name' => $lastName,
'message' => $_POST['message'] ?? '',
]);
// $response->getEventId() - unique event identifier
The formSubmit() method automatically:
- Reads
vt_vidcookie → setsclient.customId - Reads
vt_sidcookie → setssessionId - Reads
_fbp/_fbccookies → sets CAPI matching params - Extracts
emailfrom form data → setsclient.email - Captures
fbclid,utm_source,gclidfrom URL → includes in params for attribution - Forwards real client IP and user-agent to the API
This is especially important for Facebook CAPI attribution: when the JS SDK fails to send a PageView (e.g., in Facebook In-App Browser), the PHP SDK captures attribution data from the URL and forwards it server-side.
PHP SDK - Advanced (Using FormSubmitEvent Directly)
<?php
use AxiTrace\AxiTrace;
use AxiTrace\Model\Event\FormSubmitEvent;
$axitrace = AxiTrace::init('sk_live_YOUR_SECRET_KEY');
// Create form submit event with full control
$event = new FormSubmitEvent('quote-request');
// Set client identifiers
$event->setClientCustomId($_COOKIE['vt_vid'] ?? '');
$event->setClientEmail($_POST['email'] ?? '');
$event->setSessionId($_COOKIE['vt_sid'] ?? '');
// Set form data
$event->setFormParams([
'email' => $_POST['email'],
'first_name' => $_POST['first_name'],
'last_name' => $_POST['last_name'],
'phone' => $_POST['phone'],
'company' => $_POST['company'],
'message' => $_POST['message'],
]);
// Add Facebook CAPI data for higher match quality
$event->setPhone($_POST['phone']); // Plain text - auto-hashed by AxiTrace
$event->setFirstName($_POST['first_name']); // Plain text - auto-hashed by AxiTrace
$event->setLastName($_POST['last_name']); // Plain text - auto-hashed by AxiTrace
$response = $axitrace->track($event);
Server-Side (cURL)
# Lead form with Facebook CAPI data
curl -X POST https://stat.axitrace.com/v1/form/submit \
-u "sk_live_YOUR_SECRET_KEY:" \
-H "Content-Type: application/json" \
-d '{
"label": "quote-request",
"client": {
"customId": "value-from-vt_vid-cookie",
"email": "prospect@company.com",
"phone": "+1-555-123-4567"
},
"sessionId": "value-from-vt_sid-cookie",
"params": {
"email": "prospect@company.com",
"first_name": "John",
"last_name": "Doe",
"phone": "+1-555-123-4567",
"company": "Acme Corp",
"city": "New York",
"state": "NY",
"zip": "10001",
"country": "US",
"message": "Need enterprise pricing",
"fbp": "fb.1.1234567890.987654321",
"fbc": "fb.1.1234567890.AbCdEfGhIjKl"
}
}'
Server-Side (Python)
import os
import requests
from flask import request, redirect
secret_key = os.environ.get('AXITRACE_SECRET_KEY')
@app.route('/contact', methods=['POST'])
def contact_form():
# Read AxiTrace SDK cookies - CRITICAL for user profile linking
visitor_id = request.cookies.get('vt_vid')
session_id = request.cookies.get('vt_sid')
# Read Facebook cookies for CAPI matching
fbp = request.cookies.get('_fbp')
fbc = request.cookies.get('_fbc')
# Get form data
email = request.form.get('email')
first_name = request.form.get('first_name')
last_name = request.form.get('last_name')
# Process your form (save to DB, send email, etc.)
# ...
# Track to AxiTrace
requests.post(
'https://stat.axitrace.com/v1/form/submit',
auth=(secret_key, ''),
json={
'label': 'contact-form',
'client': {
'customId': visitor_id,
'email': email,
},
'sessionId': session_id,
'params': {
'email': email,
'first_name': first_name,
'last_name': last_name,
'message': request.form.get('message'),
'fbp': fbp,
'fbc': fbc,
}
}
)
return redirect('/thank-you')
Response
Success Response (200 OK)
{
"success": true,
"eventId": "form-1234567890123456789",
"action": "form.submit"
}
Error Responses
| Status | Error | Description |
|---|---|---|
400 |
label is required |
Missing or empty form label/identifier |
400 |
client must have at least one identifier (customId, id, uuid, or email) |
No client identifier provided in the client object |
400 |
params is required |
Missing params object |
400 |
params.email must be a non-empty string |
Email field is present in params but empty or not a string |
400 |
params.email must be a valid email address |
Email is present but fails format validation (must contain @ and a dot) |
401 |
unauthorized |
Invalid or missing API key |
E-commerce Integration Examples
WordPress Contact Form 7
// Track Contact Form 7 submissions
document.addEventListener('wpcf7mailsent', function(event) {
var formId = event.detail.contactFormId;
var inputs = event.detail.inputs;
// Extract form data
var formData = {};
inputs.forEach(function(input) {
formData[input.name] = input.value;
});
if (typeof Axitrace !== 'undefined' && Axitrace._instance) {
Axitrace._instance.track('form.submit', {
label: 'cf7-form-' + formId,
email: formData['your-email'],
first_name: formData['your-name']?.split(' ')[0],
last_name: formData['your-name']?.split(' ').slice(1).join(' '),
message: formData['your-message']
});
}
});
React Contact Form
// ContactForm.jsx
import { useState } from 'react';
export function ContactForm() {
const [formData, setFormData] = useState({
email: '', firstName: '', lastName: '', message: ''
});
const handleSubmit = async (e) => {
e.preventDefault();
// Submit to your backend
const response = await fetch('/api/contact', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(formData)
});
if (response.ok) {
// Track form submission - fires Facebook Lead + TikTok SubmitForm
if (typeof Axitrace !== 'undefined') {
Axitrace._instance.track('form.submit', {
label: 'contact-form',
email: formData.email,
first_name: formData.firstName,
last_name: formData.lastName
});
}
}
};
return (
<form onSubmit={handleSubmit}>
<input type="email" value={formData.email}
onChange={(e) => setFormData({...formData, email: e.target.value})}
required />
{/* ... other fields */}
<button type="submit">Send</button>
</form>
);
}
Best Practices
- Use meaningful labels - Choose descriptive form labels like
contact-form,newsletter-footer,quote-requestfor easy identification in analytics - Track after successful submission - Only fire the event after the form is successfully processed, not on submit attempt
- Include email when available - Email is crucial for user identification and Facebook CAPI matching. Set it in both
client.emailandparams.emailfor maximum coverage. - Include phone when available - Phone is available in both
client.phoneandparams.phoneand significantly improves Facebook CAPI match quality - Pass Facebook cookies - Include
fbpandfbcfor better ad attribution (the PHP SDK does this automatically) - Server-side tracking preferred for lead forms - Track server-side to ensure data is captured even if the page redirects after submission
- Use the PHP SDK - Prefer
$axitrace->formSubmit()over manual cURL calls. The SDK auto-reads cookies, captures attribution params (fbclid, utm_*), and forwards client IP/user-agent. - Don't double-track - Choose either JS SDK or server-side for each form submission. Sending both creates duplicate Lead/SubmitForm events with different eventIDs.