Skip to content

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 ​

  1. On each submit, the script sends form.submitted with formId, formName, action and page.
  2. The script finds the identifier fields: email, phone, LinkedIn, X, Instagram, GitHub, TikTok, YouTube, website, company number and VAT number. It uses the autocomplete value, 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 example e-post, sähköposti and organisationsnummer.
  3. The script sends an identifier only when its value is valid. For example, a company number must have a correct checksum.
  4. The script sends the company, title, country, first name, last name and company size as the properties company, title, country, firstName, lastName and companySize.
  5. 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.
  6. 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 autocomplete value of current-password or new-password
  • One-time code fields, with an autocomplete value of one-time-code
  • Payment fields, with an autocomplete value that starts with cc- or transaction-
  • Hidden fields, with the hidden attribute, the type hidden or a parent with the hidden attribute
  • 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 ​

  1. Add data-lg-event to the form to give the event a name.

  2. Add data-lg-capture with the fields to send as properties.

  3. Add data-lg-identify with the fields to send as identifiers, in the form identifier=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-ignore to 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.