Pixel Event Code Generator for Facebook and Meta Ads

Generate Facebook Pixel event code for Purchase, Lead, AddToCart and every standard event — with value, currency, content IDs and an event ID that matches your Conversions API payload.

Runs in your browser. Nothing is uploaded.For Meta

Pixel Event Code Generator for Meta

1 Build or check

What do you want to do?

A plain number — no currency sign.

Use the same IDs as the id column of your Meta catalog. The price goes into the Conversions API version only.

The same ID must go in the Conversions API event. For Purchase, the order number works well.

2 Your pixel code / check results

Fill in the settings above — your result appears here instantly.

Next step Fill fbc and fbp in the Conversions API payload correctly — the click and browser IDs raise match quality.

Build fbc and fbp values

Rules last checked: against the official pages:

How to use the event code generator for the Facebook Pixel

This event code generator for the Facebook Pixel writes the fbq() call for any standard event and the Conversions API event that pairs with it. Names, parameters and the event ID position follow Meta's Meta Pixel reference and its deduplication guide.

  1. Pick the event. Choose Purchase, Lead, AddToCart or any other standard event. Only the parameters Meta lists for it are shown. Pick Custom event for your own name.
  2. Fill in value and currency. Purchase can't be sent without them. Type the value as a plain number.
  3. Add product lines. One line per product with ID, quantity and price. The tool builds contents and content_ids from them.
  4. Set the event ID. Use the order number, or the name of a variable your page already has. The same ID goes into the server event.
  5. Copy both code boxes. Box 1 goes on your site. Box 2 is the JSON your developer or server tool sends to the Conversions API endpoint in box 3.
Pixel event code generator for Facebook showing a Purchase fbq call with eventID and the matching Conversions API JSON

What to do next: add the event to your site

The Meta Pixel base code must already be on every page, between <head> and </head>. The event code then runs after it, only on the page or click that matters.

Plain HTML

  1. Open the template of your confirmation page (or the page with the button).
  2. Paste box 1 below the base code. For click events, change #your-button to your button's selector — the code works even in <head>.
  3. Replace the example value, currency and order number with the real ones your server prints for that order.

Common Meta Pixel event errors and fixes

Facebook Pixel purchase event not working: wrong capitals

Standard event names are case-sensitive: purchase or AddtoCart are not Purchase or AddToCart. Meta's reference lists the exact spelling of every standard event; anything else is a different event.

Event ID inside the parameters

The ID belongs in a separate fourth argument written {eventID: '…'}, with a capital I and D. Put inside the value/currency object, or spelled eventId, it is not read as the deduplication key.

Facebook pixel duplicate events

Purchases count twice when the pixel and the Conversions API send different IDs, different event names, or no ID at all. Another cause is a second fbq('track', 'PageView') — the base code already sends one.

Value sent as text

value: '$49.90' is a string with a symbol. Send value: 49.90 and put the currency in currency: 'USD', using the 3-letter code.

content_ids that don't match the catalog

Meta's catalog rules say the product id must exactly match the pixel's content_ids for Advantage+ catalog ads, including letter case. Sending parent product IDs while the catalog lists variants breaks the match.

Custom event sent with track

Own names like TookQuiz need fbq('trackCustom', …). The track method is for Meta's standard events.

Frequently asked questions

What does Facebook Pixel purchase event code look like?

fbq('track', 'Purchase', {value: 142.50, currency: 'USD'}, {eventID: 'ORDER-1001'}); — the event name, an object with the parameters, and an optional fourth object with the event ID. It runs below the Meta Pixel base code on your order confirmation page.

Which parameters should a Purchase event include?

Meta requires value and currency for Purchase. Add content_ids or contents (each entry with id and quantity) if you run Advantage+ catalog ads — the IDs must match your catalog exactly. content_type is product or product_group.

How do I test Facebook Pixel events?

Open Events Manager › Data sources › your pixel › Test Events and browse your site — events show up live. For the Conversions API, copy the test code from the same Test Events screen into test_event_code, and remove it before going live.

What is event_id and why does it matter with the Conversions API?

It is the ID Meta uses to spot the same event arriving twice — once from the browser pixel (eventID) and once from your server (event_id). When both have the same event name and ID, Meta keeps one, within a 48-hour window. Your order number works well.

Why is my Facebook Pixel purchase event not working?

Most often: the event name is written purchase instead of Purchase, value or currency is missing, value is text with a currency sign, the event code runs before the base code, or the code sits on a page shoppers never reach. Paste your code into Check my code to find which.

Can I create custom events with the Meta Pixel?

Yes: fbq('trackCustom', 'TookQuiz', {…});. Meta says custom event names must be strings of up to 50 characters. You can turn them into custom conversions — up to 100 per ad account.

  • Build Meta's fbc click value from an ad click link, and bulk-check fbc and fbp values for the time, case and hashing mistakes that break matching.

    Meta
  • Check the server events you send to Meta's Conversions API for hashing mistakes, missing fields and weak customer details, and get a fixed version.

    Meta
  • Get custom pixel code for Shopify that sends checkout and cart events to Meta, Google, TikTok and Pinterest, plus a checker for wrong event names.

    ShopifyMetaGoogleTikTokPinterest
  • Get TikTok pixel code for purchases, leads and other events with the 2025 event names, value, currency and a matching Events API event.

    TikTok
  • Get Pinterest tag code for checkouts, leads and sign-ups, with value, order ID, an event ID for the Conversions API and enhanced match.

    Pinterest
  • Find why your Meta catalog match rate is low: compare catalog IDs with the product IDs your pixel sends and see which ID format breaks the match.

    Meta

Need help setting this up? Talk to EmproIT