How to Use the Facebook Pixel

 


Get Started

The Meta Pixel is a snippet of JavaScript code that loads a small library of functions you can use to track Facebook ad-driven visitor activity on your website. It relies on Facebook cookies, which enable us to match your website visitors to their respective Facebook User accounts. Once matched, we can tally their actions in the Facebook Ads Manager so you can use the data to analyze your website's conversion flows and optimize your ad campaigns.


By default, the Pixel will track URLs visited, domains visited, and the devices your visitors use. In addition, you can use the Pixel's library of functions to:


  • track conversions, so you can measure ad effectiveness

  • define custom audiences, so you can target visitors who are more likely to convert

  • set up Advantage+ catalog ads campaigns


Requirements


In order to implement the Pixel, you will need:


  • access to your website's code base

  • your Pixel's base code or its ID

  • access to the Facebook Ads Manager


Base Code


Before you can install the Pixel, you will need your Pixel's base code, which you can find in the Ads Manager > Events Manager. If you have not created a Pixel, follow these instructions to create one — all you will need is the Pixel's base code 


(step 1).


The base Pixel code contains your Pixel's ID in two places and looks like this:


—----------------------------------------------------------------------------------------------

<!-- 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-goes-here}');

  fbq('track', 'PageView');

</script>

<noscript>

  <img height="1" width="1" style="display:none" 

       src="https://www.facebook.com/tr?id={your-pixel-id-goes-here}&ev=PageView&noscript=1"/>

</noscript>

<!-- End Facebook Pixel Code →

—----------------------------------------------------------------------------------------------


We have separate the code in 2 part


Part 1:

<!-- Meta 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', '260933000105298');

</script>

<!-- End Meta Pixel Code →


Part 2:

<script>

 fbq('track', 'PageView');

</script>


Google Tag


<!-- Google Tag Manager -->

<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':

new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],

j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=

'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);

})(window,document,'script','dataLayer','GTM-PRHN2THJ');</script>

<!-- End Google Tag Manager -->


In the Tag manager we have added 2 tag 




Share your thoughts

Previous Post Next Post

نموذج الاتصال