CJM
PixelManual tracking

Capture a lead

Every trackLead field, complete examples, and form matching.

Use trackLead to send information a person entered into your form to CJM. A form_submit event or track('lead_submit') call does not replace lead capture.

If you also need to configure form questions and scoring, start with Lead Forms. This guide remains the complete reference for fields sent by the Pixel.

Connect your form

  1. Install the Pixel and make sure window.CJMPixel is available.
  2. Choose a stable form identifier. If the form is configured in CJM, use its formId, not the Pixel ID.
  3. Map contact fields to contact and answers to form_responses.
  4. Call trackLead once from the successful submission handler, after validation. A click on “Submit” alone does not confirm success.
  5. Submit a test and check the contact and, if answers were supplied, the form submission in CJM.

Signature and fields

window.CJMPixel.trackLead(data, eventName?)

FieldTypeRequiredWhat to provide
dataobjectYesThe three groups below.
contactobjectYesContact details.
contact.firstNamestringYesFirst name.
contact.emailstringYesEmail address; validate it in your form.
contact.lastNamestringNoLast name.
contact.phonestringNoPhone number, preferably with country code.
contact.<other field>JSON-serializable valueNoExtra details such as company; these do not imply automatic CRM field mapping.
form_responsesarrayYesOne entry per answer, or [].
form_responses[].questionIdstringYes, per entryStable question identifier.
form_responses[].questionTextstringYes, per entryQuestion text required by the Pixel's public contract.
form_responses[].answerstringYes, per entryAnswer; convert numbers and multiple selections to strings.
source_metadataobjectYesOriginating form.
source_metadata.formIdstringYesForm identifier, matching the configuration in CJM when one exists.
source_metadata.form_namestringNoReadable form name.
eventNamestringNoSecond argument, defaults to lead_submit.

Do not supply cid, sid, timestamps, or consent yourself: the Pixel adds them as permitted. trackLead does not accept options, tags, or destinations.

Complete example

Replace this sample data with actual submitted values.

window.CJMPixel.trackLead({
  contact: {
    firstName: 'Giulia',
    lastName: 'Rossi',
    email: 'giulia@example.com',
    phone: '+390212345678',
    company: 'Example Srl'
  },
  form_responses: [
    { questionId: 'service', questionText: 'Servizio richiesto', answer: 'Demo CJM' },
    { questionId: 'team_size', questionText: 'Dimensione del team', answer: '12' }
  ],
  source_metadata: {
    formId: 'richiesta-demo',
    form_name: 'Richiesta demo'
  }
}, 'demo_request');

Minimal example

window.CJMPixel.trackLead({
  contact: { firstName: 'Giulia', email: 'giulia@example.com' },
  form_responses: [],
  source_metadata: { formId: 'richiesta-demo' }
});

form_responses: [] is valid. CJM receives the lead, but only creates an answers record when the array contains at least one answer. An unknown formId does not prevent sending; the submission will not be linked to a matching form configuration.

Connect successful form submission

This defines a handler to call from your form’s success callback, passing its <form> element. Fields must be named firstName, email, and service. This callback name is not an automatic CJM event: connect it to the system that actually saves your form.

function onContactFormSaved(form) {
  const fields = new FormData(form);
  window.CJMPixel.trackLead({
    contact: {
      firstName: String(fields.get('firstName') ?? ''),
      email: String(fields.get('email') ?? '')
    },
    form_responses: [{
      questionId: 'service',
      questionText: 'Servizio richiesto',
      answer: String(fields.get('service') ?? '')
    }],
    source_metadata: { formId: 'richiesta-demo', form_name: 'Richiesta demo' }
  });
}

Refusing cookies does not block explicitly submitted form data. Visitor and session identifiers still depend on their respective consent signals. This technical behavior does not replace your form's privacy notice.

The function does not return delivery confirmation or replace your website's form storage. Do not display “Request sent” solely because trackLead ran.

Troubleshooting

  • No lead: check contact, form_responses, and source_metadata. Put firstName and email inside contact.
  • Missing answers: check that the array is nonempty and questionId values match the expected questions.
  • Duplicate requests: avoid calling from both the click handler and submission success handler.
  • Missing earlier journey: check consent and identity matching. A lead sent without identifiers might not link to earlier visits.

On this page