Facebook Pixel Code code example
Example 1: where to add facebook pixel code
To install the pixel, we highly recommend that you add its base code between
the opening and closing <head> tags on every page where you will be tracking
website visitor actions. Most developers add it to their website's persistent
header, so it can be used on all pages.
Placing the code within your <head> tags reduces the chances of browsers or
third-party code blocking the pixel's execution. It also executes the code
sooner, increasing the chance that your visitors are tracked before they leave
your page.
Once you have added it to your website, load a page that has the pixel. This
should call fbq('track', 'PageView'), which will be tracked as a PageView event
in the Events Manager.
Example 2: facebook pixel
// REPLACE '1234567890' with your Facebook pixel ID
<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', '1234567890');
fbq('track', 'PageView');
</script>
<noscript><img height="1" width="1" style="display:none"
src="https://www.facebook.com/tr?id=1234567890&ev=PageView&noscript=1"
/></noscript>