serkankaya.
Türkçe sürüm
Let’s work together ↗

Meta Pixel Setup: Step-by-Step Installation and Event Testing

How to set up the Meta Pixel: base code, GTM and platform integrations, standard events, cookie consent, testing with Data Advisor and common mistakes.

Meta Pixel setup consists of creating a Pixel in Events Manager, adding its base code to every page of your site and then defining conversion events such as purchases, form submissions or appointments. On its own, the base code only measures page views; the real value for ad optimization lies in conversion events sent with the right parameters. The setup is finished when the events have been verified in Events Manager and in the testing tool.

In this post I explain how the Pixel works, the three installation paths, standard events, cookie consent and testing. At the end I share the checklist I use before going live.

What is the Meta Pixel and how does it work?

The Meta Pixel is a JavaScript library loaded on your site’s pages that passes visitor actions to Meta through the fbq() function. According to Meta’s developer documentation, by default the Pixel tracks the URLs visited, the domains visited and the visitor’s device.[1] The actions of matched visitors are reported in Ads Manager.

The Pixel was formerly called the Facebook Pixel; the Turkish interface calls it “Meta pikseli”. It does three jobs: measuring conversions, building custom audiences from site visitors and feeding Advantage+ catalog ads.[1]

Visitor action fbq() call Meta Pixel Events Manager
Every action on the page is handed to the Pixel through fbq(); the Pixel sends the event from the browser to Meta.

Because the Pixel runs in the browser, it is affected by the browser’s restrictions. Ad blockers, cookie restrictions and visitors who decline consent mean that some events never reach Meta. That is why the Pixel needs to be complemented by a server-side source, namely Meta Conversions API. I explain the difference between browser-side and server-side measurement in detail in the post on server-side tracking.

How do you set up the Meta Pixel?

Short answer

How do you set up the Meta Pixel?

To set up the Meta Pixel, you create a Pixel in Events Manager and add its base code between the head tags on every page of your site. Once the code loads, a PageView event is sent automatically. Then conversions such as purchases, form submissions or appointments are defined with standard events and verified in Events Manager.

  1. Open Events Manager in your Meta business account
  2. Create a new Pixel as a website data source
  3. Choose an installation method: code, GTM or a platform integration
  4. Add the base code to the head section of every page
  5. Define conversion events with fbq('track')
  6. Test the events with Events Manager and Data Advisor

Before you start, three kinds of access need to be in place: access to the site’s code or tag manager, the Pixel’s base code or ID, and access to Ads Manager.[1] In a company setting, the Pixel should be created under the company’s Meta Business Portfolio (Business Manager), not in a personal account. Otherwise, ownership of the data becomes a dispute when an agency or an employee changes.

The base code

The base code carries the Pixel ID in two places and sends a PageView event on every load. Meta recommends leaving that line intact.[1] The code looks like this:

<!-- Meta Pixel Code -->
<script>
!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', 'PIXEL_ID');
fbq('track', 'PageView');
</script>
<!-- End Meta Pixel Code -->

The code that Events Manager gives you also includes a noscript block below this. That block sends the PageView through a 1x1 image request in browsers with JavaScript disabled; add it unchanged together with the code.

Meta recommends adding the base code between the opening and closing <head> tags on every page where you want to measure activity.[1] Placing it in the head reduces the chance that other scripts block the Pixel. Because the code runs early, it also increases the chance that an event is sent before the visitor leaves the page. If your mobile site is separate from the desktop site, add the Pixel to both versions.

Three installation paths

There are three common ways to add the Meta Pixel to a site: writing the code directly into the template, using a tag manager such as Google Tag Manager, or turning on the built-in Meta integration of a platform such as Shopify, WooCommerce, ikas or Ticimax.

MethodWho it suitsWhat to watch
Direct codeSites with their own template and access to a developerEvery event needs a code change and a release
Google Tag ManagerTeams managing several ad platforms in one placeConsent and trigger order must be set up correctly
Platform integrationStores running on a hosted e-commerce platformCheck which events are sent with which parameters

Meta notes that the Pixel works in most tag managers, but its recommended method is adding the code directly to the head.[1] In most projects I prefer GTM. The reason is that Google Ads, GA4 and Meta tags are fed from the same data layer (dataLayer) and the same consent state.

Which Meta Pixel events should you set up?

The events to set up are the standard events that correspond to the business’s real conversion steps: ViewContent, AddToCart, InitiateCheckout and Purchase in e-commerce; Lead, Contact, Schedule or CompleteRegistration on lead generation sites. Meta tracks conversions in three ways: standard events, custom events and custom conversions.[2]

A standard event is an action predefined by Meta and sent under a fixed name. It is called as fbq('track', 'Purchase', {...}). A custom event is sent under a name you choose with fbq('trackCustom', ...). A custom conversion is defined in Events Manager with a URL or event rule and requires no extra code.[2]

Standard eventWhen it firesKey parameters
ViewContentWhen a product or service page is viewedcontent_ids, content_type, value, currency
AddToCartWhen a product is added to the cartcontents, value, currency
InitiateCheckoutWhen the checkout flow startsnum_items, value, currency
PurchaseWhen payment is completedvalue and currency required
LeadWhen a form is submitted successfullyvalue, currency (optional)
ScheduleWhen an appointment is bookedoptional

According to Meta’s standard events reference, currency and value are required for the Purchase event. If you use Advantage+ catalog ads, you also need to send contents or content_ids.[3] A purchase event looks like this:

fbq('track', 'Purchase', {
  value: 1250.00,
  currency: 'TRY',
  content_ids: ['SKU-1042'],
  content_type: 'product'
}, { eventID: 'order-10482' });

The eventID in the last parameter is used for deduplication when the same event is also sent from Conversions API. Meta recommends adding this ID as the fourth parameter of the fbq('track') call when the Pixel and Conversions API run together.[3] The same value goes into the event_id field of the server event.

Where should an event fire?

An event should fire where the action is actually completed. Meta’s conversion tracking documentation gives two examples: when the purchase confirmation page loads, or when a button is clicked.[2] I use button clicks only to measure intent; I tie optimization events such as Purchase and Lead to a confirmed success.

Misleading triggers

  • Lead fires when the form button is clicked
  • Purchase fires again every time the thank-you page is refreshed
  • value is hard-coded as a fixed number
  • Currency is missing or wrong

Correct triggers

  • Lead fires after the server has accepted the form
  • Purchase fires once per order, with the order number
  • value is read from the actual order total
  • currency matches the currency the payment was taken in
If an optimization event is not tied to a confirmed success, Meta bids on conversions that never happened.

On sites that need cookie consent, the Meta Pixel is set up so that it sends no data until the visitor consents. Meta offers a consent API for this: fbq('consent', 'revoke') is called before init, and fbq('consent', 'grant') is called once the visitor consents.[4] Meta notes that the revoke call has to be made on every page.

fbq('consent', 'revoke');
fbq('init', 'PIXEL_ID');
fbq('track', 'PageView');

// When the visitor accepts marketing cookies in the cookie banner:
fbq('consent', 'grant');

If you use GTM, you can tie the same logic to the signal from your consent management platform (CMP). I cover the Google-side equivalent in the post on Consent Mode v2. Feeding both platforms’ consent state from the same banner prevents one from sending data while the other is still waiting for consent.

According to Meta’s GDPR page, the Pixel receives HTTP headers, the Pixel ID and Facebook cookie, button clicks and form field names. Form field values are not collected unless they are explicitly sent through advanced matching or conversion tracking.[4] Advanced matching strengthens event matching by adding details such as email or phone to the fbq('init') call. The Pixel hashes these values with SHA-256 in the browser.

In health tourism, the most valuable event usually happens in the CRM rather than on the site. I cover how measurement is designed in this sector in the post on health tourism offline conversions.

How do you test whether the Meta Pixel is working?

The Meta Pixel is tested in two places: in the browser with the Meta Ads Data Advisor extension and on Meta’s side with Events Manager. After adding the base code, Meta recommends opening a page with the Pixel and checking whether a new PageView event appears in Events Manager. If it does not appear, wait a few minutes and refresh the page.[1]

Meta Ads Data Advisor is a free browser extension formerly called Meta Pixel Helper. According to Meta’s documentation, it works in Chrome and Edge and shows the number of Pixel events fired on the page on the extension icon.[5] The side panel lists event names, parameters and missing fields such as content_ids, value and currency. For existing Pixel Helper users, the extension updates to Data Advisor automatically.

  1. Verify the base code

    Open several different page templates on the site. Data Advisor should show a single Pixel and one PageView on each page.

  2. Run the event flow end to end

    View a product, add it to the cart, complete the checkout or the form. At each step, confirm that the expected event fires exactly once.

  3. Check the parameters

    Confirm that value and currency in the Purchase event match the order and that content_ids match the IDs in your catalog.

  4. Look at Events Manager

    Confirm the events reach Meta in the Test Events screen and the event list; if browser and server events arrive together, check that they are deduplicated.

  5. Test the consent scenario

    Browse the site after rejecting cookies. No Pixel request should be sent without consent, and events should start once consent is given.

Keep your own test orders and form submissions separate. Test data in a live account affects reports and optimization, even if only briefly.

What are the most common Meta Pixel setup mistakes?

The most common Meta Pixel setup mistakes are loading the Pixel twice, firing conversion events at the wrong moment, missing value and currency, and skipping consent management. Most of these mistakes are invisible when the code is added; they only show up when the conversion count in reports is compared with the order or lead count in the back end.

  • Duplicate Pixel: A platform integration and manually added code run at the same time, so every event is counted twice.
  • Wrong Pixel ID: A test or old Pixel stays on the live site, and data flows into another account.
  • Event repeated on refresh: Purchase or Lead fires again every time the thank-you page is refreshed.
  • Fixed value: value is sent as the same number for every order, which makes the ROAS report meaningless.
  • Currency mismatch: A site that sells in Turkish lira still sends currency: 'USD'.
  • Event name with sensitive data: A custom event name or URL contains treatment, illness or financial status details.
  • Relying on one source: Only the Pixel is used, and events lost in the browser are never recovered.

If the Pixel and Conversions API run together, the server side of measurement needs the same discipline. I explain how a server container is set up in the post on server-side GTM setup. If you want to measure traffic sent to WhatsApp, the post on WhatsApp conversion tracking applies the same logic to that channel.

Pre-launch checklist

Before taking the Pixel live, I verify each of the items below one by one. The list applies regardless of the installation method.

Meta Pixel pre-launch check0/8

Conclusion

Meta Pixel setup consists of creating the Pixel in the right account, adding the base code to every page from a single source and sending real conversion steps as standard events with the right parameters. Cookie consent and sensitive data rules, especially in healthcare, are an integral part of the setup. The setup is complete when the events have been verified in Data Advisor and Events Manager.

The next step is to fill in the events the Pixel misses from the server. You can continue with the Conversions API post, and see how measurement connects to ad strategy on the performance marketing page. I cover the e-commerce side of this setup in my e-commerce SEO and ad management work as well.

Key terms

Meta Pixel
Meta Pixel is a JavaScript snippet added to a website that sends visitor behavior to Meta. It matches visitors to Meta accounts through Facebook cookies and supplies data for conversion measurement, custom audiences and catalog ads. It was formerly called the Facebook Pixel.
Standard event
A standard event is a conversion action predefined by Meta and sent under a fixed name such as Purchase, Lead, AddToCart or Schedule. It is fired with the Pixel's fbq('track') function, can carry parameters and can be selected directly as an optimization goal.
Custom conversion
A custom conversion is a conversion type defined in Events Manager by a URL or event rule, with no extra code on the site. For example, it can count visitors who reach pages containing /thank-you/ in the address. Meta restricts custom conversions that suggest disallowed information such as health conditions.
Meta Ads Data Advisor
Meta Ads Data Advisor is a free browser extension for Chrome and Edge, formerly called Meta Pixel Helper. It shows the Pixel events firing on a page, their parameters and any errors, and it also helps set up Pixel, Conversions API and catalog connections.
Advanced matching
Advanced matching is a Meta feature that sends a visitor's email, phone number or name along with Pixel events. The Pixel hashes these values with SHA-256 in the browser; the goal is to match events to Meta accounts more accurately.

Frequently asked questions

Does Meta Pixel setup cost anything?

No, creating a Meta Pixel and adding it to your site is free. You create the Pixel in Events Manager, add the code to your site and pay no extra license fee. The real costs are the time of whoever sets it up and your ad budget.

Where on the site does the Meta Pixel code go?

Meta recommends adding the base code between the opening and closing head tags on every page where you want to measure activity. On most sites this is the shared header template used across all pages. Placing the code in the head makes it run early and increases the chance that an event is sent before the visitor leaves.

How do I know whether the Meta Pixel is working?

After opening a page with the Pixel, check your Pixel's details in Events Manager; if you see a new PageView event, the base code is working. The event may take a few minutes to appear. On the browser side, the Meta Ads Data Advisor extension shows which events fire on the page and with which parameters.

Can the Meta Pixel be installed with Google Tag Manager?

Yes. Meta says the Pixel works in most tag managers, although its recommended method is adding the code directly to the head. If you use GTM, fire the base code on all pages, send events with separate tags and manage cookie consent in the same container.

Is the Meta Pixel enough without Conversions API?

It can be a starting point for a small site, but browser restrictions and ad blockers keep some events from reaching Meta. Meta recommends using Conversions API alongside the Pixel. When you use both, the same event has to be matched with an event_id.

Sources

  1. Meta for Developers: Meta Pixel Get Started
  2. Meta for Developers: Conversion Tracking
  3. Meta for Developers: Standard Events Reference
  4. Meta for Developers: General Data Protection Regulation
  5. Meta for Developers: Meta Ads Data Advisor