Cookie preferences

Choose which optional cookies EndFrame may use on this site. Analytics and advertising tools load only if you allow them, and you can change your mind any time from “Cookie settings” in the footer. Whatever you choose, this tab keeps the campaign labels from the link that brought you, and they are saved with your account if you sign up. Read the Cookie Policy.

Needed for the site to work, such as remembering this choice. Always on.

Lets us load analytics tools through Google Tag Manager, including Google Analytics and Microsoft Clarity session recordings, to understand how the site is used.

Allows advertising tags to measure our ad campaigns. None run on this site today. It also keeps ad click IDs from the page address for this tab, and saves them with your account if you sign up.

Skip to main content

Meta Pixel Setup: How to Create a Dataset, Install the Code and Verify Events

A from-scratch guide for advertisers who have never installed the Meta Pixel: what a dataset is, how to create one, three ways to install the base code, how to add a first Purchase event, and how to confirm Meta receives it.

The EndFrame Team7 min read

Meta Pixel setup comes down to three things: a dataset in Meta Events Manager, the pixel base code on every page of your site, and at least one event that marks a result you care about, such as a purchase or a lead. You create the dataset, copy its ID, install the code by hand, through your website platform or through a tag manager, then check that PageView and your event arrive. This guide walks through each step from an empty account, plus the mistakes that make a new pixel report wrong numbers from day one.

Dataset vs pixel: what you are creating

Events Manager asks you to create a dataset, while most plugins and tutorials ask for a pixel ID. A dataset is the container in Events Manager that stores the events a business sends to Meta, from a website, an app, offline sales or messaging. The Meta Pixel (formerly the Facebook Pixel) is one of those sources: the JavaScript code on your website that reports what visitors do in their browser.

The two share one number. The ID of a dataset created for a website is the ID that goes into the pixel code, so a settings field labelled Pixel ID, Dataset ID or Meta Pixel ID wants the same value. Meta's developer documentation still calls it the Pixel ID.

Step 1: create the dataset in Events Manager

  1. 1Open Events Manager and, if you have more than one, select the right business portfolio in the left menu.
  2. 2Click Connect data, choose Web as the data source and click Next.
  3. 3Click Create new dataset, give it the business or website name rather than a campaign name, because one dataset normally serves the whole site, and click Create.
  4. 4If you manage several ad accounts, select the ones that should use this dataset.
  5. 5Choose a setup method. Set up manually gives you the base code to paste yourself (you may need to click to see other ways to set up before it appears); Meta lists other options alongside it.
  6. 6Follow the remaining screens to the installation instructions. Meta offers the Conversions API here too, but the pixel works on its own and the Conversions API can be added later.

Meta rewords these screens from time to time. If a label does not match, check Meta's Business Help Centre article on creating a dataset for your pixel. To find the ID later, select your dataset under Data sources in Events Manager, where Meta calls it the Dataset ID. It also appears twice in the base code, the surest place to read it.

Step 2: pick an install route

There are three common ways to get the base code onto your pages. Use exactly one of them.

RouteHow it worksSuits
Manual codeYou paste the base code into the header template of the site so that it loads on every page.Custom-built sites, and anyone who can edit the site's code or has a developer.
Partner integrationThe website platform adds the pixel once you connect your Meta account and choose the pixel. On Shopify this is the Facebook & Instagram sales channel, under Settings and then Share data settings. WordPress uses a plugin, covered in our Meta Pixel on WordPress guide.Hosted shops and site builders. There is no code to edit, and many integrations send the standard shopping events for you.
Tag managerYou add the pixel as a tag in a tool such as Google Tag Manager, for example the base code in a Custom HTML tag, set to fire on all pages.Teams that already manage their tags and consent rules in a tag manager.

Meta's browser extension, Meta Ads Data Advisor, can also set up the pixel without code on some platforms. Meta's documentation lists Google Tag Manager, Shopify and WooCommerce, and setup needs a login, admin access to the Meta ad account and access to the platform.

If you move from one route to another, remove the old code first. Shopify's help centre tells merchants to delete pixel code pasted into the theme before connecting a pixel through Facebook & Instagram, because otherwise the store runs more than one pixel and reports duplicate or incorrect data.

Step 3: install the base code by hand

The base code is a short script that Meta generates with your ID filled in. Paste it between the opening and closing head tags of every page, which in practice means the shared header template or the header code field of your site builder. Meta gives two reasons: code there is less likely to be blocked by browsers or other scripts, and it runs sooner, so more visitors are recorded before they leave. The script does three things:

  • It loads Meta's pixel library, a file called fbevents.js, from connect.facebook.net. This defines the fbq function that every later call uses.
  • It runs fbq('init', '1234567890123456'), with your own ID in place of the example number, which tells the library where to send events.
  • It runs fbq('track', 'PageView'), which reports a PageView event each time a page loads.

Leave the PageView call in place, as Meta recommends. PageView is the event that proves the pixel is installed, and it records the address of each page, which Events Manager can use to define custom conversions by URL (for example any URL containing /thank-you). The last lines, wrapped in a noscript tag, are a fallback image request for browsers with JavaScript switched off. That is the second place your ID appears, so if you swap the ID, change it in both.

Step 4: add your first standard event

PageView only tells Meta that someone visited. To measure and optimise for results, send an event when the result happens. Meta defines 17 standard events, including Lead, CompleteRegistration, AddToCart and Purchase, and our guide to standard events, custom events and custom conversions explains how to choose. Purchase makes a good worked example because it carries money.

On the order confirmation page, add this call inside a script block: fbq('track', 'Purchase', {value: 49.00, currency: 'GBP'}); Your shop system should fill in the real order total as a plain number without a currency symbol, and the three-letter code of the currency charged. The base code must already be on the page. The event call can sit anywhere in the body and can run on page load, as here, or on an action such as a button click. For a lead form, the equivalent is fbq('track', 'Lead'); on the confirmation step.

Some events may not need code at all. Partner integrations usually send the shopping events themselves, and since 3 August 2026 the option to detect and add standard events automatically is pre-selected when you set up a new pixel through Meta Ads Data Advisor. You can turn it off in Events Manager under Settings, Track events automatically without code. Check whether one of these already sends an event before adding it by hand, so the same action is not reported twice.

Step 5: verify that events arrive

Turn off any ad blocker first, because it stops the pixel and the checking tools along with it. Then check in three places.

  1. 1Events Manager. Load a page of your site, then open the dataset in Events Manager. A new PageView event means the pixel is installed. If nothing shows, Meta advises waiting a few minutes and refreshing.
  2. 2The Test events tab. In the same dataset, open Test events and follow the on-screen steps for testing browser events. Events from your test session show up there. Place a test order and confirm that Purchase arrives once, with the right value and currency.
  3. 3Meta Ads Data Advisor. This free extension for Chrome and Edge was called Meta Pixel Helper until Meta renamed it. A badge with a dot or a number on its icon shows pixel events fired on the page, and no badge means no pixel was found. Click the icon for a side panel that lists the pixels and events. Basic checks work without logging in. Our guide to Meta Ads Data Advisor statuses and errors explains each message.

For a quick outside check, our free pixel inspector fetches a public page and lists the pixels found in its initial HTML. It cannot see tags that a tag manager injects later or after consent, so use the checks above for those setups.

Setup mistakes that distort the numbers

  • Two base codes on one page. A theme snippet plus a plugin, or a tag manager tag plus hard-coded script, makes every event fire twice. Keep one route and delete the other.
  • The pixel only on the thank-you page. Meta then sees buyers and nobody else, so you cannot build audiences from other visitors or record earlier steps such as AddToCart. The base code belongs on every page.
  • Purchase on the wrong page, or a value sent as text such as '£49.00'. Fire it only on the confirmation step, with a plain number and a three-letter currency code.
  • No consent handling where the law requires it. Meta's setup page notes that you may have to comply with the GDPR, and under EU and UK cookie rules (the ePrivacy Directive and PECR) a marketing pixel generally needs the visitor's consent before it loads. Our guide to the Meta Pixel and cookie consent shows how.
  • The wrong ID. Copy it from the dataset your ad account actually uses, not from an old or test dataset in the same business.

What to set up next

Next, add the remaining events for your funnel. Then add the Conversions API, which sends events from a server so that Meta does not depend on the browser alone; Facebook Pixel vs Conversions API explains how the two fit together. Finally, test both sides before you trust the numbers, following how to test Meta Pixel and Conversions API events.

Whichever server-side tool you choose, the same rule applies. EndFrame, for example, forwards conversions to the Meta Conversions API, and Meta keeps a single copy only when the site passes the same event name and event_id to the browser pixel and to the server call. That is easier to plan when you add your first event than to retrofit later.

Frequently asked questions

Is the Meta Pixel the same as the Facebook Pixel?

Yes. Meta Pixel is the current name for what used to be called the Facebook Pixel, and it still loads its library from connect.facebook.net. In Events Manager the pixel now sits inside a dataset, which is why the same number is labelled Dataset ID in some places and Pixel ID in others. An older pixel may already have been converted into a dataset automatically, keeping its number, so check Events Manager before creating a new one.

Where do I find my Meta Pixel ID?

Open Events Manager, choose Data sources and select your dataset. Meta calls the number the Dataset ID, and it is shown with the dataset's details. Do not confuse it with your ad account ID or business ID, which look similar. The surest place to read it is the base code: on a live site it sits inside the fbq init call in the page source.

How long does a new Meta Pixel take to show data?

A PageView normally shows in Events Manager soon after you load a page that carries the pixel. Meta's instructions say to wait a few minutes and refresh if it is missing. The Test events tab is quicker for checking, because it shows events from your own test session. If nothing arrives, look for an ad blocker, a consent banner holding the pixel back, or a wrong ID.

Does the event code go in the head or the body?

The base code goes in the head section of every page. Event calls such as fbq('track', 'Purchase') can go anywhere in the body, as long as the base code is already on the page. They can run when the page loads, which suits a confirmation page, or when a visitor does something, such as clicking a button or submitting a form.

Try EndFrame

Add a server-side path for your conversions.

EndFrame collects events first-party and forwards conversions server-side to Meta, GA4, TikTok, and webhooks with event-ID deduplication — then credits each conversion to its campaign, with the visit-to-conversion path you can audit.

No credit card required

Keep reading