How to install facebook tracking pixel in magento?

How to install facebook tracking pixel in magento?

July 16, 2026 · Illustrated author avatarBy Stefan Bogdanescu
How to install facebook tracking pixel in magento?

Installing Facebook Tracking Pixel on Magento: A Comprehensive Guide

As an e-commerce store owner or developer, tracking customer behavior is crucial for optimizing your sales and marketing strategies. One powerful tool for this purpose is the Facebook tracking pixel.

Where to Install the Facebook Pixel

The official documentation suggests adding the pixel code in the success.phtml file located under app/design/frontend/XXXX/YYYY/template/checkout/success.phtml. However, if you’re using a third-party theme like Ultimo, the directory structure might vary.

In most cases, including the Ultimo theme, the success.phtml file can be found in two locations:

  • Custom theme: app/design/frontend/Ultimo/default/template/checkout/success.phtml
  • Base theme: app/design/frontend/base/default/template/checkout/success.phtml

Step-by-Step Installation Process

1. Access the correct success.phtml file

If you’re using a custom theme, navigate to the success.phtml file located in your theme directory. If not, use the one found in the base theme.

2. Add the Facebook Pixel code

Scroll down to the bottom of the success.phtml file and paste the Facebook pixel code provided by Facebook Ads Manager (see example below).

<!-- 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'); // Insert your pixel ID here
fbq('track', 'Purchase');
</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 -->

Replace 'YOUR_PIXEL_ID' with your actual Facebook pixel ID.

3. Save and test the changes

Save the file, then navigate to a product page in your Magento storefront. Make a purchase or complete an order to trigger the pixel’s events. Wait for a few minutes before checking if Facebook can verify the pixel.

Why Your Pixel Isn’t Verifying

If Facebook still cannot verify your pixel after following these steps, there are a few possibilities:

  • Pixel ID: Ensure you’ve replaced 'YOUR_PIXEL_ID' with your actual pixel ID.
  • No events fired: Make sure you’ve completed an action in Magento that triggers the fbq('track', 'Purchase') event, such as a successful order placement or checkout.
  • Caching issues: Clear all caches and refresh your page. Sometimes, browser caching can interfere with scripts.

Conclusion

Installing the Facebook tracking pixel on a Magento store requires careful attention to file locations, especially when using third-party themes like Ultimo. By following this guide, you’ll be able to accurately track customer behavior and optimize your marketing efforts.

Remember, keeping your themes and core files up-to-date is essential for maintaining compatibility with best practices and official documentation.

For more advanced Magento customizations and development tips, consider visiting Laravel Company. We provide expert services and resources to help you get the most out of your e-commerce platforms.

Checkout Performance Themes Customers

Our network