# FB Pixel

The Facebook Meta Pixel is a piece of JS code on your website that can help you better understand the effectiveness of your advertising and the actions people take on your site, like visiting a page or adding a product to their cart. You'll also be able to see when customers took an action after seeing your ad on Facebook and Instagram, which can help you with retargeting.

This code is used for local landing pages loaded into the tracker. If there is no access to the code (offer redirect), you can use the Conversions API setting. See Facebook integration.

  1. Create traffic source in the tracker using a ready-made Facebook template and add the source to the campaign and the campaign parameters will be filled in automatically, including the pixel parameter:

  1. Open the landing page in the Editor and go to index.html (or index.php).

  2. Add between <head> and </head> that code:

<script>
var date = new Date();
date.setTime(date.getTime() + (5 * 24 * 60 * 60 * 1000));
if (!'{pixel}'.match('{')) {
  document.cookie = "pixel={pixel}; " + "expires=" + date.toUTCString() + "";
}
</script> 
1
2
3
4
5
6
7

WARNING

If another parameter in the campaign is used to transfer the pixel, for example, px, you need to replace it in the script: from document.cookie = "pixel={pixel} to document.cookie = "pixel={px}

Example:

  1. Open the file or page where you want to install the pixel, for example, a thank you page, and add the following code:
<script>
var matches = document.cookie.match(new RegExp("(?:^|; )" + 'pixel' + "=([^;]*)"));
var pixel = matches ? decodeURIComponent(matches[1]) : undefined;
</script>

<!-- Facebook 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);
fbq('track', 'Lead');
</script>
<!-- End Facebook Pixel Code -->
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19

Example of a ready-made configuration option:

How to check the pixel operation?

To check the functionality of the pixel, use the Google Chrome extension — Meta Pixel Helper. When you visit a page with the pixel, a small number will appear on the Facebook Pixel Helper icon, indicating the number of pixel events. Clicking on the icon will expand the panel, showing an overview of the page's pixels, including warnings and errors.

How to hide referrer?

Add that code between <head> and </head>:

<meta name="referrer" content="no-referrer">` between tags`<head>...</head>
1