Adding Facebook Pixel

Hey you all, we are using X-Pro and wanted to add Facebook Pixel to our header.

I noticed from another older post that you had someone add the below code to their functions.php file - unfortunately that code just added the Pixel in twice. Can I just use the first part of the script that places it into wp_head and leave off the second half. That seems to work but I wasn’t sure why you had the two parts.

/*Pixel base Code*/
function fb_print_pixel_base() { ?>

<!-- PLACE YOUR BASE PIXEL CODE HERE -->

 <?php }

 add_action( 'wp_head', 'fb_print_pixel_base', 999 );



/*Pixel Event Code*/
function fb_print_pixel_event() { ?>

<!-- PLACE YOUR EVENT PIXEL CODE HERE -->

 <?php }

 add_action( 'x_before_site_begin', 'fb_print_pixel_event' );

Hi @Boans,

Thank you for writing in, yes you can use only the first block of code (the /*Pixel base Code*/)

Some users separate their Pixel Event Code, that is what the second block is for. Actually, you might need that second block of code for Pixel Event that should only place on a specific page (or not).

Create and Install a Facebook Pixel

Hope it helps,
Cheers!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.