Accepting orders Order now

Facebook Pixel event code generator

Generate Meta Pixel base code and standard event code for purchases, leads and more, with an event ID for deduplication. Free, no sign-up, runs in your browser.

Pixel Event GeneratorPrivate · nothing is saved
Your code appears here, ready to copy. Test it in Events Manager before you rely on it.

What the pixel event generator builds

The Meta Pixel records actions on your website, such as purchases, leads and sign-ups, so Facebook can report on your ads and show them to people likely to take the same action. Each action is sent as an event. This generator writes the code for one event at a time, with the right parameters, and can add the Pixel’s base code if it is not on your site yet. Meta documents every standard event and parameter; the generator uses those names exactly.

Choosing the right event

  • Purchase for a completed order, on the order confirmation page, with the real order value and currency.
  • Lead when someone submits a form you consider a lead.
  • AddToCart and InitiateCheckout for the steps before a purchase.
  • CompleteRegistration, Subscribe or StartTrial for accounts and subscriptions.
  • Schedule and Contact for bookings and enquiries.

Track the few actions that matter for your business and send each one only when the action is actually completed, not when a page with a form simply loads.

Value, currency and content IDs

For purchases, always send value and currency. Without them, Meta cannot calculate return on ad spend or optimise for value. On a real store, the value should come from the order itself rather than a fixed number; the generator shows a fixed value so you can see the format, and your developer or platform should replace it with the order total. content_ids should match the product IDs in your catalog if you run catalog ads.

Event IDs and the Conversions API

Many stores send the same event twice: once from the browser with the Pixel and once from the server with the Conversions API. That is a good setup, as long as both copies carry the same event ID so Meta keeps only one. With the deduplication option on, the generator creates an event ID in the browser. Your server event must send the same ID, which usually means generating it once, for example from the order number, and passing it to both.

Where to paste the code

  1. Base code: once, in the head of every page. Skip it if your platform or a plugin already installs the Pixel; two base codes cause double counting.
  2. Page-load events: only on the page that confirms the action, such as the thank-you page.
  3. Click events: once, on pages where the button exists, after the base code. The CSS selector must match the button exactly.

In WordPress, a code snippets plugin or your theme’s header and footer settings are the usual places. On hosted platforms, use the platform’s own Meta integration where it exists instead of pasting code.

Pixel code on popular platforms

Where your site runs decides whether you need this code at all. On Shopify, the official Facebook and Instagram sales channel sends standard events for you, and adding manual code usually creates duplicates. On WooCommerce and WordPress, an official or well-maintained integration plugin is normally the better choice for purchases, while generated code is useful for extra actions such as a booking button. On site builders such as Wix or Squarespace, use the built-in Meta integration and add custom code only where the platform allows it. On custom-built sites, generated code is a good starting point for your developer, who should replace the example values with real ones from your system.

Common Pixel event mistakes

  1. Two base codes on the same page, often one from a plugin and one pasted by hand.
  2. Purchase on the checkout page instead of the confirmation page, so every visit to checkout counts as a sale.
  3. A fixed value such as 1.00 on every purchase, which makes return on ad spend meaningless.
  4. The wrong currency, so reports convert values that were already in your store’s currency.
  5. Lead on page load rather than on form submission, so a lead is counted each time someone opens the form page.
  6. Different event IDs in the browser and the server, which stops deduplication from working.

Event match quality

In Events Manager, each event has an event match quality score. It reflects how well Meta can connect an event to a person, which affects how useful the event is for reporting and optimisation. Browser events alone usually score lower. Server events sent through the Conversions API can include extra details such as a hashed email address, when your customers have given them and you are allowed to use them, and that tends to raise the score. You do not need a perfect score; you need events that are accurate, sent once and matched well enough to learn from.

Test before you trust it

Open Events Manager, choose your Pixel, go to Test Events and follow the instructions to open your site. Trigger the action yourself. The event should appear within seconds with the parameters you expect. If it appears twice, you have duplicate code or missing deduplication. If it does not appear, check that the base code loads and that the selector or page is correct.

Once events arrive correctly, keep an eye on them after any change to your site: a new theme, checkout app or cookie banner can quietly stop events from firing. A quick test in Events Manager after each change takes two minutes and saves weeks of misleading reports. If you run campaigns optimised for purchases or leads, also compare the weekly totals in Ads Manager with your own store or CRM. A small gap is normal; a sudden jump or drop usually means something in the setup has changed.

FAQ

Questions about this tool

Do I need the base code if I use Shopify or WooCommerce?

Usually not. Their official Meta integrations install the Pixel for you. Adding the base code again causes double counting.

Is the value in the code my real order value?

No. It is an example. On a live store the value should come from the order itself, through your platform or developer.

What is the event ID for?

It lets Meta match the browser event with the same event sent by the Conversions API, so a purchase is counted once instead of twice.

Can I use custom events?

Yes, with fbq trackCustom, but standard events are easier to optimise for. Start with standard events where one fits.

Is anything I enter saved?

No. The code is generated in your browser and nothing is sent to us.

Related service

Facebook Pixel Setup

Want Pixel and Conversions API installed and tested event by event for you? From $49.

Free tool

Ad Policy Checker

Paste your ad text and see which phrases often lead to rejected ads, with a safer way to say each one.

Free tool

Appeal Letter Generator

Answer a few questions and get a calm, factual review request for a disabled ad account or profile.