Installing the FB pixel in the Keitaro tracker
When downloading a landing page to Keitaro, there are several options for installing the FB pixel. Statically and dynamically. You can also add a standard (full) pixel or a short (truncated) one.
Static full pixel
To do this, you need to install the pixel scripts before the closing </head> tag in the following files:
  • index.php - in the root of the landing page,
  • invoice2/index.php - the "Thank You" page.
The second option is in:
  • trackers.php - displayed on the landing page itself
  • trackers_order.php - on the "Thank You" page.
The base pixel code containing the PageView event is placed on the main page:

<!-- 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', '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>
<!-- End Facebook Pixel Code →

On the "Thank You" page, in addition to PageView, you also need to add the Lead event to track the conversion:

<!-- 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', 'your_pixel_ID');
fbq('track', 'PageView');
</script>
<script>
fbq('track', 'Lead');
</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>
<!-- End Facebook Pixel Code →

Static short pixel
In this case, only the Lead event will trigger on the "Thank You" page.

To do this, add the code either to the trackers_order.php file or before the closing </head> tag in the invoice2/index.php file:
<!-- Facebook Pixel Code -->
<img height="1" width="1" style="display:none"
src="https://www.facebook.com/tr?id=your_pixel_ID&ev=Lead&noscript=1"/>
<!-- End Facebook Pixel Code →
Dynamic full pixel
We have the option to set up a dynamic pixel and pass it via the website URL; this way, you can run traffic to a single landing page using different ad flows simultaneously.

To do this, append the parameter ?fb_pixel=your_pixel_ID to the landing page link you plan to use in the ad campaign (if the link has no other parameters yet) or &fb_pixel=your_pixel_ID (if there are other parameters). Then, you can simply change the ID in the link without modifying the landing page itself.

In this case, the pixel code shown in the previous section will be automatically generated on the necessary pages with the pixel ID specified in the URL, namely:
  • The base pixel code containing the PageView event will be installed on the main page.
  • On the "Thank You" page - PageView and the Lead event to track the conversion.
Dynamic short pixel
For its installation and correct operation, you need to change the code in two files.
In the pieces/fb_pixel.php file to the following code:
<?php if (isset($lead)): ?>
<img height="1" width="1" src="https://www.facebook.com/tr?id=<?= $fb_pixel ?>&ev=Lead=1"/>
<?php endif ?>
In the pieces/trackers/fb_pixel.php file to the following code:
<?php if (isset($lead)): ?>
<img height="1" width="1" src="https://www.facebook.com/tr?id=<?= $pixel_id ?>&ev=Lead=1"/>
<?php endif ?>
Moreover, the Lead event can be replaced with any other event.
How to check if the pixel works correctly
To do this, use the Facebook Pixel Helper extension.
Follow your link, submit a test lead, and see if all events are displayed correctly:

Read more about testing a link: guide
PageView event on the main page of the website with a full pixel:
PageView and Lead events after placing an order on the "Thank You" page with a full pixel:
Lead event after placing an order on the "Thank You" page with a short pixel: