Analytics Lab / Instrumentation

Meta Pixel Sandbox

Example Meta Pixel calls attached to common page elements. Each interaction runs a local fbq stub and prints the event in the Conversions API request format. No data is sent.

Pixel ID
META-PIXEL-ID
Test event code
META-SANDBOX
Browser endpoint
https://www.facebook.com/tr
Conversions API endpoint
https://graph.facebook.com/v18.0/<pixel-id>/events

Tracked elements

Each element declares its fbq command, event name and parameters in data-meta-* attributes. Standard events use fbq('track'). Anything else uses fbq('trackCustom') so it does not mix with standard event reporting.

Lead and sign-up events

Trial starts, demo bookings and lead forms. These are the events most often used as campaign optimization goals.

fbq('track', 'StartTrial')

Start free trial

Standard StartTrial event. Send value, currency and optionally predicted_ltv so the trial can be valued in reporting.

Event
StartTrial
Interaction
click
Action source
website

Not fired yet.

Parameters
 

fbq('track', 'Schedule')

Book a demo

Standard Schedule event, fired when a visitor books a meeting. Fire it on the booking confirmation, not on the button that opens the calendar.

Event
Schedule
Interaction
click
Action source
website

Not fired yet.

Parameters
 

fbq('track', 'Lead')

Demo request form

Standard Lead event on form submit. Do not put personal data in event parameters. Pass hashed identifiers through advanced matching in fbq('init') instead.

Event
Lead
Interaction
submit
Matching
em, external_id via init

Not fired yet.

Parameters
 

Content engagement

Downloads, video progress and newsletter sign-ups. These are typically used for retargeting audiences rather than as optimization goals.

fbq('trackCustom', 'file_download')

File download link

Meta has no standard download event, so this is a custom event. The parameters record the file and where the link sits on the page.

Event
file_download
Interaction
click
Prevent default
true (demo only)
Download pricing guide (PDF)
Parameters
 

fbq('trackCustom', 'video_start')

Video progress

Start, 50% and complete for a product video. Meta has no standard video events, so all three use trackCustom.

Not fired yet.

Parameters
 

fbq('track', 'CompleteRegistration')

Newsletter sign-up

A free newsletter sign-up maps to CompleteRegistration (or Lead). Meta's Subscribe event is meant for paid subscriptions.

Not fired yet.

Parameters
 

Commerce

Standard commerce events. content_ids must match the IDs in your product catalog for dynamic ads. value and currency are required on Purchase.

fbq('track', 'AddToCart')

Add to cart

Fired when a product is added to the cart. contents lists each item with its quantity and price.

Not fired yet.

Parameters
 

fbq('track', 'InitiateCheckout')

Begin checkout

Fired when the visitor starts checkout. Send the cart contents, item count and cart value.

Not fired yet.

Parameters
 

fbq('track', 'Purchase')

Purchase

Fired on the order confirmation page. If the same order is also sent through the Conversions API, pass a shared ID as { eventID } in the fourth argument so Meta can deduplicate.

Not fired yet.

Parameters
 

Support

Post-purchase support interactions. Chat uses the standard Contact event. Case resolution and surveys are custom events.

fbq('track', 'Contact')

Open support chat

Standard Contact event for chat, phone, email or SMS contact. The parameters record the channel and topic.

Not fired yet.

Parameters
 

fbq('trackCustom', 'support_case_resolved')

Support case resolved

Records a closed support ticket. In production this is usually sent server-side through the Conversions API, since the browser is rarely open when the case closes.

Not fired yet.

Parameters
 

fbq('trackCustom', 'survey_submit')

Satisfaction survey

Records a satisfaction score and comment. Do not send free-text comments if they may contain personal data.

Not fired yet.

Parameters
 

Interface events

Preferences, consent, dialogs and inline help. These are custom events and are mainly useful for product analysis, not ad optimization.

fbq('trackCustom', 'theme_change')

Theme toggle

Records a switch between light and dark themes. The parameters include the previous and new value.

Interaction
click
Dynamic
toggle state + parameters

Current theme: Light

Theme set to light.

Parameters
 

fbq('trackCustom', 'consent_update')

Marketing email consent

Records a change to an email preference. This is separate from pixel consent, which is set with fbq('consent', 'grant') or fbq('consent', 'revoke').

Interaction
change
Fields
preference + consent
Parameters
 

fbq('trackCustom', 'modal_open')

Upgrade dialog

Opening the dialog fires modal_open. The two buttons inside fire modal_dismiss and modal_accept.

Interaction
click
Actions
open / dismiss / accept

Dialog closed.

Parameters
 

fbq('trackCustom', 'tooltip_toggle')

Inline help tooltip

Records when a help tooltip is shown or hidden, and which help article it references.

Interaction
click
Dynamic
visible / hidden

Tooltip hidden.

Parameters
 

fbq('trackCustom', 'feedback_score')

Article feedback slider

Records a 1 to 5 rating for a help-center article. The parameters include the score and the scale maximum.

Interaction
change
Scale
1–5

No rating yet.

Parameters
 

Sharing and page events

Sharing, printing, scroll depth and client-side errors. All are custom events.

fbq('trackCustom', 'share')

Copy link

Copies the page URL to the clipboard and records a share with method copy.

Not fired yet.

Parameters
 

fbq('trackCustom', 'share')

Share to X

The same share event with method social and the destination network.

Not fired yet.

Parameters
 

fbq('trackCustom', 'page_print')

Print page

Records a print action. In production, attach it to the print button or the beforeprint window event.

Not fired yet.

Parameters
 

fbq('trackCustom', 'scroll_depth')

Scroll depth

An Intersection Observer fires once when the marker below is fully visible. In production the marker sits at 90% of the page height.

Scroll marker (fires once)

Waiting for scroll.

Parameters
 

fbq('trackCustom', 'client_error')

Client error

Records a non-fatal error, such as a failed API call during checkout. Keep error messages free of personal data.

No errors logged.

Parameters
 

Meta Pixel base code

Place the base code in the document head. Replace META-PIXEL-ID with your pixel ID. Pass advanced matching fields (for example em, external_id) as the third argument to fbq('init').

&lt;script&gt;
  !function(f,b,e,v,n,t,s){
    if(f.fbq) return;
    n=f.fbq=function(){ n.callMethod ?
      n.callMethod.apply(n,arguments) : n.queue.push(arguments);
    };
    if(!f._fbq) f._fbq=n;
    n.push=n; n.loaded=!0; n.version='2.0';
    n.queue=[]; t=b.createElement(e); t.async=!0;
    t.src=v; s=b.getElementsByTagName(e)[0];
    s.parentNode.insertBefore(t,s);
  }(window, document,'script','https://connect.facebook.net/en_US/fbevents.js');
  fbq('init', 'META-PIXEL-ID');
  fbq('track', 'PageView');
&lt;/script&gt;