Capture forms
The script sends each form submit automatically. It also finds the email address and the company fields, and identifies the visitor. Use this page to control what the script sends.
What the script does by default
- On each submit, the script sends
form.submittedwithformId,formName,actionandpage. - The script finds the identifier fields: email, phone, LinkedIn, X, Instagram, GitHub, TikTok, YouTube, website, company number and VAT number. It uses the
autocompletevalue, the field type, the name, the id, the label and the placeholder, in this order. It knows the words in English and in the Nordic and EU languages, for examplee-post,sähköpostiandorganisationsnummer. - The script sends an identifier only when its value is valid. For example, a company number must have a correct checksum.
- The script sends the company, title, country, first name, last name and company size as the properties
company,title,country,firstName,lastNameandcompanySize. - The script adds
_detected, with the name of the field of each identifier. The key is the identifier name and the value is the field name. - The script reads the value of a field only after the visitor grants the analytics purpose. Before that, the event has the form data and an empty
_detected. The script sends identifiers only after consent.
Fields that the script never sends
- Each
textarea - Password fields, with an
autocompletevalue ofcurrent-passwordornew-password - One-time code fields, with an
autocompletevalue ofone-time-code - Payment fields, with an
autocompletevalue that starts withcc-ortransaction- - Hidden fields, with the
hiddenattribute, the typehiddenor a parent with thehiddenattribute - A radio or a box that the visitor does not select, and a button
- Personal ID numbers, for example a Swedish personal identity number
Procedure: choose the fields yourself
Add
data-lg-eventto the form to give the event a name.Add
data-lg-capturewith the fields to send as properties.Add
data-lg-identifywith the fields to send as identifiers, in the formidentifier=field:html<form data-lg-event="contact.submitted" data-lg-capture="company,role" data-lg-identify="email=work_email,phone=tel"> <input name="work_email"> <input name="tel"> <input name="company"> <input name="role"> </form>
Stop the form events
- To stop the detection of identifiers on all forms, set
data-forms="no-identify"on the script tag. - To stop all form events, set
data-forms="off"on the script tag. - To stop the events of one form, add
data-lg-ignoreto the form.
Forms from other vendors
A form that the page shows is visible to the script. One submit sends one event: the core form.submitted, with _detected and the profile properties. The adapter of the vendor adds no second event. For this reason the package has no adapter for Webflow or WordPress forms.
A form in a frame of a different domain, for example a HubSpot or a Typeform form, is not visible to the script. The adapter of the vendor reads its message or callback and sends its event, for example hubspot.form_submitted. Refer to Adapters for the list.