Meta Pixel — Lead Event
Meta Pixel — Lead Event
Fires a Meta Pixel Lead event with custom parameters sourced from GTM variables. It's a self-contained Custom HTML tag: paste it into GTM, and re-paste this file to pick up updates.
Want a higher Event Match Quality? Use the Advanced Matching Lead event instead — same event, plus the lead's email, phone, name, and a persistent
external_id.
What it does
- Reads payload values from GTM variables (traffic source, page path, optional form name)
- Calls
fbq('track', 'Lead', payload, { eventID })
Prerequisites
- The base Meta Pixel must be installed and firing on All Pages — Page View, before this tag fires. Without it,
fbqis undefined and the tag throws an error without sending the event. - A GTM variable named
cJS - Traffic Sourcereturning last-touch traffic source (Custom JavaScript variable). - A GTM variable named
cJS - Ad Placementreturning the ad placement (Custom JavaScript variable). - A GTM variable named
cJS - Custom Event IDreturning a globally unique event ID (Custom JavaScript variable, plus itsDLV - gtm.uniqueEventIdcompanion) — sent aseventIDso Meta can dedupe browser Pixel and Conversions API events. - Built-in GTM variable
Page Pathenabled. - (Optional) A Lookup Table variable named
LUT - Convert Form ID to Textmapping form IDs to human-readable form names — uncomment the line inchtml-lead-config.htmlto send it.
Installation
Step 1: Create the Custom HTML tag
In GTM, go to Tags → New:
- Click Tag Configuration → choose Custom HTML
- Paste the contents of
chtml-lead-config.htmlinto the HTML field - (Optional) Uncomment the
form_nameline if you have theLUT - Convert Form ID to Textvariable set up - Click Triggering → choose your form-success trigger (e.g.,
Custom Event - GF Form Successfrom the Gravity Forms listener, or any other trigger that signals a lead) - Name the tag:
Meta - Event - Lead - Form Submit - Save
Step 2: Preview and publish
- Click Preview to test in Tag Assistant
- Submit a form on your site — verify the Lead event fires by:
- Checking the Network tab in DevTools for a request to
facebook.com/trwithev=Lead - Using the Meta Pixel Helper Chrome extension (should show a
Leadevent with your custom parameters)
- Checking the Network tab in DevTools for a request to
- Once verified, publish your container
Payload structure
The event is sent with the following parameters:
| Parameter | Source | Notes |
|---|---|---|
lead_type | Hardcoded Form Submit | Custom param — change in chtml-lead-config.html if this tag fires for a different lead type (e.g., Phone Call) |
traffic_source | {{cJS - Traffic Source}} | Custom param — last-touch traffic source |
content_name | {{Page Path}} | Meta standard param — page where the lead occurred |
ad_placement | {{cJS - Ad Placement}} | Custom param — ad placement |
form_name | {{LUT - Convert Form ID to Text}} | (Optional) Custom param — human-readable form name |
eventID | {{cJS - Custom Event ID}} | Meta's browser/server dedupe key — passed in the event options (the second object passed to fbq), not the custom-data payload |
Known limitations
- One lead type per tag:
lead_typeis hardcoded in the tag. Duplicate the tag for different lead types (Phone Call, Demo Request, etc.) and edit the value. - Event deduplication needs both sides: the tag sends
eventIDfromcJS - Custom Event ID, but Meta only dedupes if your server-side CAPI integration sends the same value asevent_idfor the same event. - No consent mode integration: Handle in your CMP separately.
Disclaimer
This script packages Meta's standard Pixel snippet for distribution via the Marketing Toolkit. The underlying Pixel code is provided by Meta Platforms, Inc. and subject to their terms.
Provided as-is under the MIT License. Test thoroughly before relying on it for revenue attribution.
Packaged by W.H. Boggs — whboggs.com → Free Meta Ads audit
The code
<!--
Marketing Toolkit — Meta Pixel — Lead Event
Version: v1.3.0
Last updated: 2026-08-13
https://github.com/whboggs/marketing-toolkit
-->
<script></script>