Meta · Track an eventStep 1 of 3

Track Lead

The Lead event fires when a visitor submits a form — contact form, demo request, newsletter signup, consultation request, etc. Critical for service businesses, B2B lead-gen, healthcare, and real estate.

Example of a contact form on a website
Lead fires the moment the visitor clicks the form's submit button.

1. Find your form’s selector

We need a way for the script to find your form. The easiest way is by its id attribute. Open the page with your form in a browser, right-click the form → Inspect. Look at the <form> element in DevTools and note its id= attribute. Common ones: contact-form, lead-form, signup-form.

Browser DevTools showing a form element with an id attribute
If your form has no id, add one (e.g. <form id='contact-form'>).

2. Copy the snippet

Replace #contact-form with your form’s actual #+id (e.g. #newsletter-form).

Option A — pbq (recommended)

contact-page.html
<!-- Place inside the <body> of the page that contains the form,
     AFTER the AdsPing script in <head>. -->
<script>
  document.querySelector('#contact-form')
    .addEventListener('submit', function () {
      pbq('track', 'Lead', {
        content_name: 'Contact form',
        value: 0,
        currency: 'USD'
      });
    });
</script>

Option B — dataLayer

contact-page.html
<!-- Place inside the <body> of the page that contains the form,
     AFTER the AdsPing script in <head>. -->
<script>
  document.querySelector('#contact-form')
    .addEventListener('submit', function () {
      window.dataLayer = window.dataLayer || [];
      window.dataLayer.push({
        event: 'generate_lead',
        form_name: 'Contact form',
        value: 0,
        currency: 'USD'
      });
    });
</script>

3. Where to paste it

Paste it inside the <body> of the page that contains your form — ideally near the bottom, after the form HTML, so the form element exists when the script runs.

Code editor showing the Lead snippet pasted near the bottom of the contact page body
Place it AFTER your form's HTML, ideally just before </body>.

Multiple forms on your site?

Add the same snippet to every page that has a lead form, each time pointing at that page’s form ID. AdsPing will forward each one to Meta with the content_name you set, so you can tell them apart in reporting.

4. Test it

Open the page in a fresh tab, fill out the form with test data, and submit. Within 10 seconds, a new Lead row appears in your AdsPing pixel’s Recent Events list with a green Success badge.

AdsPing Recent Events showing a Lead event with a Success badge

✓ Lead is live.

Every form submission on your site is now forwarded to Meta via the Conversions API.