How to Set Up a Facebook Retargeting Pixel: Step-by-Step Installation Guide

If you have ever wondered how to set up a Facebook retargeting pixel without hiring a developer, this guide is built for you. We walk through the exact clicks inside Meta Events Manager, show you where the code goes on WordPress, Shopify and custom-built sites, and finish with a verification step so you know the pixel is actually firing before you spend a single euro on ads.

Realistic timing: 20 to 30 minutes from zero to a verified, firing pixel. Grab a coffee and keep two browser tabs open (your website admin and Events Manager).

What a Facebook Retargeting Pixel Actually Does

The Meta Pixel (still widely called the Facebook pixel) is a small snippet of JavaScript you place on every page of your website. When someone lands on your site, the snippet loads and tells Meta: this browser visited this page, at this time, and did this action.

That data feeds three things:

  • Retargeting audiences: show ads only to people who viewed a product, abandoned a cart, or read a specific page.
  • Conversion tracking: see which ad produced which sale or lead.
  • Ad optimisation: Meta’s delivery system learns who converts and finds more people like them.

Important 2026 naming note: inside Events Manager, Meta now groups pixels under Datasets. A dataset contains your pixel plus any server-side (Conversions API) connection. If you see “Datasets & pixels” in the menu instead of “Pixels”, you are in the right place.

facebook pixel code laptop

Before You Start: 4-Item Checklist

What you need Where to get it
A Meta Business portfolio (Business Manager) business.facebook.com, free to create
Admin access to your website WordPress admin, Shopify admin, or FTP/CMS access
Meta Pixel Helper extension Chrome or Edge web store (free)
A cookie consent banner Required in the EU/UK before the pixel fires on tracking cookies

One pixel per website domain is enough. Do not create three pixels for the same site: you will split your audience data and slow down learning.

Step 1: Create Your Pixel in Meta Events Manager

This part takes about 3 minutes.

  1. Go to Meta Events Manager (business.facebook.com/events_manager).
  2. In the left sidebar, click Connect data sources (or the green + icon).
  3. Select Web, then click Connect.
  4. Enter a clear name for your dataset. Use your domain, for example 11h-fire.com – Main Pixel. Avoid names like “Pixel 1”.
  5. Click Create.
  6. Enter your website URL when prompted. Meta will check for an available partner integration (WordPress, Shopify, WooCommerce, Wix, Squarespace and others).

Find and copy your Pixel ID

Your Pixel ID is a 15 or 16 digit number shown directly under the dataset name in Events Manager. Copy it to a notepad: several install methods only ask for this number, not the full code.

facebook pixel code laptop

Step 2: Choose Your Installation Method

Meta offers three paths. Pick the one that matches your platform and your comfort level.

Method Best for Difficulty Time
Partner integration Shopify, WooCommerce, Wix, Squarespace Easiest 5 min
Manual code install WordPress, custom HTML/PHP sites Medium 10 min
Google Tag Manager Sites already running GTM Medium 10 min

Step 3: Install the Pixel on Your Site

Option A: WordPress (manual, the reliable route)

The pixel base code must sit in the <head> section of every page. Never paste it into a single post or page editor.

  1. In Events Manager, choose Install code manually and click Copy code.
  2. In WordPress, install a header script plugin such as WPCode or Insert Headers and Footers.
  3. Go to Settings > Insert Headers and Footers (or Code Snippets > Header & Footer).
  4. Paste the full pixel code, including the opening and closing <script> tags, into the Header box.
  5. Click Save.
  6. Clear your caching plugin (WP Rocket, LiteSpeed, W3 Total Cache) and your CDN cache.

Your base code looks like this. Replace YOUR_PIXEL_ID with your own number:

<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', 'YOUR_PIXEL_ID');
fbq('track', 'PageView');
</script>
<noscript><img height="1" width="1" style="display:none"
src="https://www.facebook.com/tr?id=YOUR_PIXEL_ID&ev=PageView&noscript=1"/></noscript>

WooCommerce shortcut

If you run WooCommerce, install the official Facebook for WooCommerce plugin instead. It connects your pixel and automatically fires ViewContent, AddToCart, InitiateCheckout and Purchase events with product IDs, which is exactly what dynamic retargeting needs.

Option B: Shopify

Shopify is the fastest setup of all. Do not paste the pixel code into theme.liquid if you use the official app, or you will get duplicate events.

  1. In your Shopify admin, go to Settings > Apps and sales channels.
  2. Install or open the Facebook & Instagram sales channel.
  3. Click Settings > Data sharing settings.
  4. Toggle Enable data sharing on and select the Maximum level (this activates the Conversions API alongside the browser pixel).
  5. Select your existing pixel from the dropdown, then confirm.

Prefer not to use the app? Go to Settings > Customer events > Add custom pixel, paste your base code there and click Connect. This sandboxed method survives theme updates.

Option C: Custom-coded site (HTML, PHP, React, Next.js)

  1. Open your global template file: header.php, index.html, _document.js or your shared layout component.
  2. Paste the base code immediately before the closing </head> tag.
  3. Upload the file and clear any server or CDN cache.
  4. For single-page apps, remember that the PageView event only fires once on load. Trigger fbq('track', 'PageView'); manually on each route change.

Option D: Google Tag Manager

  1. In GTM, create a new Tag > Custom HTML.
  2. Paste the full pixel base code.
  3. Set the trigger to All Pages.
  4. Save, then click Submit and Publish. An unpublished container fires nothing.
facebook pixel code laptop

Step 4: Add the Events That Power Retargeting

A PageView-only pixel lets you retarget “all website visitors”. That is a start, but the money is in granular audiences. Add standard events so you can retarget people by behaviour.

Event Fire it on Retargeting use case
ViewContent Product or service pages Show the exact product they looked at
AddToCart Add to cart click Cart abandonment ads
InitiateCheckout Checkout page load Highest intent, warmest audience
Lead Form thank-you page Exclude from prospecting, upsell instead
Purchase Order confirmation page Exclude buyers, measure ROAS

Two ways to add them:

  • Event Setup Tool (no code): in Events Manager open your dataset, click Add events > From the pixel > Open Event Setup Tool, enter your URL, then click buttons directly on your own site to map them to events.
  • Hard-coded: place a line such as fbq('track', 'Purchase', {value: 49.90, currency: 'EUR'}); on the confirmation page, below the base code.

Step 5: Verify the Pixel with Meta Pixel Helper

Never assume it works. Verification takes two minutes.

  1. Install the Meta Pixel Helper extension in Chrome or Edge.
  2. Open your website in a new tab (not a cached tab) and accept your cookie banner.
  3. Click the extension icon in the toolbar.
  4. You should see a green badge with your Pixel ID and a PageView event listed.
  5. Navigate to a product page and check that ViewContent appears. Add something to cart and check AddToCart.

Second confirmation inside Events Manager

Go to your dataset and open the Test events tab. Paste your website URL, click Open website, then browse. Events should appear in the live feed within seconds. This is the definitive proof that data reaches Meta’s servers, not just your browser.

Troubleshooting table

Symptom Likely cause Fix
No pixel found Cache not cleared, or code in body instead of head Purge cache and CDN, confirm placement before </head>
Pixel found, no events Consent banner blocking scripts Accept cookies, then reload and retest
Duplicate PageView Code installed twice (plugin + manual) Remove one instance, keep a single source
Purchase fires on every page Event placed in global header Move it to the confirmation page only
Low event match quality No customer data sent Enable Advanced Matching and the Conversions API

Step 6: Verify Your Domain and Set Event Priority

Browser tracking restrictions mean you must verify ownership of your domain to control which events are measured.

  1. Go to Business Settings > Brand safety and suitability > Domains.
  2. Click Add, enter your root domain (no https, no www).
  3. Verify via DNS TXT record, meta-tag in your head, or HTML file upload.
  4. Back in Events Manager, open Aggregated Event Measurement and rank up to eight events, with your most valuable conversion (usually Purchase or Lead) in position one.
facebook pixel code laptop

Step 7: Add the Conversions API (Strongly Recommended)

Ad blockers, iOS privacy settings and cookie expiry kill a meaningful share of browser-side events. The Conversions API sends the same events server to server, then deduplicates them against the pixel.

  • Shopify: already enabled when you set data sharing to Maximum.
  • WooCommerce: enable it inside the Facebook for WooCommerte plugin settings.
  • Other platforms: use Conversions API Gateway or a partner such as Stape, Zapier or Make.

Expect a measurable lift in reported conversions once both signals run together with matching event_id values.

Step 8: Build Your First Retargeting Audiences

The pixel is useless until you turn its data into audiences. Wait 24 to 48 hours for data to accumulate, then:

  1. Open Ads Manager > Audiences > Create audience > Custom audience.
  2. Select Website.
  3. Choose your pixel as the source.
  4. Pick a rule and a retention window.
  5. Name it clearly and save.

Audience recipes that work

Audience Rule Window Message angle
Cart abandoners AddToCart, exclude Purchase 7 days Reminder plus free shipping or guarantee
Product viewers ViewContent, exclude AddToCart 14 days Social proof, reviews, demo video
Engaged readers Top 25% time on site 30 days Lead magnet or newsletter
Recent buyers Purchase 180 days Cross-sell, exclude from prospecting

Minimum size: an audience needs roughly 1,000 people to deliver efficiently. Below that, widen the window to 30, 60 or 90 days.

facebook pixel code laptop

The 30-Minute Timeline

Minutes Task
0 to 3 Create the dataset and copy the Pixel ID
3 to 13 Install the code on WordPress, Shopify or custom site
13 to 20 Map key events with the Event Setup Tool
20 to 25 Verify with Pixel Helper and Test Events
25 to 30 Verify the domain and rank events in AEM

Mistakes That Quietly Waste Budget

  • Launching retargeting ads on day one. The audience is empty. Give it 48 hours minimum.
  • Running multiple pixels on one domain. Data fragments and optimisation suffers.
  • Forgetting to exclude converters. Paying to re-sell someone who already bought is pure waste.
  • Skipping the consent layer. In the EU this is a legal requirement, not an option.
  • Never checking again. Theme updates and plugin conflicts break pixels silently. Run Pixel Helper once a month.

FAQ

How do I set up retargeting on Facebook?

Install the Meta Pixel on every page of your site, let it collect visitor data for one to two days, then create a Website Custom Audience in Ads Manager based on a rule such as ViewContent or AddToCart. Finally, create a campaign and select that audience at the ad set level.

How do I set up a Meta Pixel on Facebook?

Go to Events Manager, click Connect data sources, select Web, click Connect, name your dataset, then click Create. Choose manual installation or a partner integration, place the code before the closing head tag, and confirm with Meta Pixel Helper.

Does the Facebook pixel still work in 2026?

Yes. The browser pixel still works, but it no longer captures everything on its own because of cookie and tracking restrictions. The recommended setup today is the pixel plus the Conversions API with event deduplication, which restores a large portion of the lost signal.

Where do I find my Facebook Pixel ID?

Open Events Manager, select your dataset in the left sidebar, and the 15 or 16 digit ID appears directly beneath the dataset name. You can also find it inside your site’s page source by searching for fbq('init'.

Can I use one pixel for several websites?

Technically yes, but it is not advised. Mixing domains inside one dataset makes audiences messy and attribution unclear. Create one dataset per website and share it with the relevant ad accounts in Business Settings.

How long until my retargeting audience is ready?

Most sites see usable audiences in 24 to 72 hours. Low-traffic sites may need one to two weeks. Use a 30 to 90 day retention window to build volume faster.

Do I need a developer for this?

No. On Shopify, WooCommerce, Wix and Squarespace the partner integration handles everything. On WordPress a free header-script plugin is enough. A developer only becomes useful for single-page applications, complex server-side setups or custom checkout flows.

Next Step

Now that you know how to set up a Facebook retargeting pixel, do the install today and come back in 48 hours to build your first cart abandoner audience. A correctly fired pixel is the single cheapest performance upgrade available to a small business: it costs nothing to install and it typically makes every ad euro you spend afterwards work harder.

Leave a Comment