How to add Facebook Pixel and set up events
Integrations
The Facebook (Meta) Pixel tracks what visitors do on your pages, so your Facebook and Instagram ads reach the right parents. Here is how to set it up.
You will need a Facebook business account, an ad account and your own domain connected to SleepPRO™.
1. Create your Pixel
- In Facebook Business Settings, click Settings, then Data sets & Pixels under Data sources.
- Click Add, name your Pixel and click Create. Close the "not ready yet" popup.
- Click Assign people, choose your business account, turn on Full control and click Assign.
- Click Connect assets, tick your ad account and click Add.
2. Install the Pixel
- Click All tools, then Events Manager, then your Pixel.
- Click Set up Meta Pixel, then Install code manually.
- Copy the Pixel code.
Add it to SleepPRO™, either:
- On one page: open the page editor, click Settings, paste the code in the Edit header code box of the tracking section, and click Save. Add it to every page of your funnel.
- On all your funnels at once: click your profile picture, then Settings, then Sales funnel, and paste the code in the tracking code field.
- Back in Facebook, click Continue. Turn on Automatic advanced matching if you like, and click Continue.
- Mark the base code as installed. Click Set up events. The automatic event tool does not always work, so add events by hand: choose Install using code, and add the event you want, for example View content, to your funnel settings.
- Verify your domain: go to Brand safety and suitability, then Domains, click Add, enter your domain and click Add. Paste the meta tag Facebook gives you into your page header code or your sales funnel settings, under the Pixel code, on its own line. Then click Verify domain in Facebook.
3. Test it
Click Test events, enter your website address and click Test events. The actions you take on your site should appear.
4. Avoid counting events twice (Pixel and Conversions API)
If you also use the Conversions API (CAPI), the same event can reach Facebook twice: once from the browser (Pixel) and once from the server (CAPI). A unique event ID lets Facebook recognize and merge them, so your numbers stay accurate. To set up CAPI, see How to configure the Facebook Conversions API on SleepPRO™.
With CAPI in place, the event ID is sent automatically through CAPI. In your Pixel code, add the matching placeholder for each event. Copy these as they are:
- Purchase: fbq('track', 'Purchase', {}, {eventID: '%FACEBOOK_PURCHASE_EVENT_ID%'});
- Appointment: fbq('track', 'Schedule', {}, {eventID: '%FACEBOOK_EVENT_ID%'});
- View content: fbq('track', 'ViewContent', {}, {eventID: '%FACEBOOK_EVENT_ID%'});
- Lead: fbq('track', 'Lead', {}, {eventID: '%FACEBOOK_NEW_LEAD_EVENT_ID%'});
The placeholders are replaced with the real IDs automatically.
To check it works:
- Pixel: visit your page and use the Facebook Pixel Helper browser extension to see events fire with their ID.
- CAPI: browse your site to trigger server events. Visiting a page fires View content or Lead. Make a test purchase to capture purchase amounts.
- Open Meta Events Manager to confirm both are tracked and merged.
Purchase amounts and upsells
- Use the Purchase event to track the amount and currency. Physical products use the product's currency, digital products and subscriptions use the price plan's currency.
- The whole order value, including order bumps and upsells, is sent with the purchase event.
- CAPI on your thank you page picks up every purchase in the order (main offer, order bumps and upsells) in one event.