Installing Facebook pixel (without using third party plugin)

Hi there,

I am trying to install a facebook pixel on my site. I pinched some code from another thread and tried implementing it along with the code for the pixel from Facebook but no luck (screenshot of error attached). Any advice?

Hi There,

Thank you for writing in, first off if you have not installed a child theme on your site yet, please install it.

How To Setup Child Themes

Then login to your server via FTP or cPanel’s File Manager and navigate to /wp-content/themes/x-child/

Open/edit the child theme file functions.php file and add the code below:

/*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' );

Replace the PLACE YOUR * PIXEL CODE HERE phrase with the actual pixel codes.

Hope it helps,
Cheers!

Thank’s heaps really appreciate it, looks like I got half way - using pixel helper I can see that the pixel is installed on the page, but, the event isn’t working (screenshot attached). Screenshot of my code also below (sorry when I paste it in as text half of it disappears - is there a proper way to send code that prevents this?), something I should change?

Hi There,

Please update the code for the pixel event to this:

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

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

 <?php }

 add_action( 'wp_head', 'fb_print_pixel_event', 1000 );

Thanks,

Hey @friech, no change unfortunately - still says pixel code didn’t load. Any other suggestions? Thanks, Ariane

Hey Ariane,

Please give us WP Admin access in a Secure Note so we could check your setup and if the codes are being outputted. I also moved your screenshots in a secure note as those contain sensitive information. If the code is successfully outputted and your Facebook Pixel integration still does not work, I’d recommend you use a third party plugin like Pixel Cat because we are not Facebook Pixel integration experts and there is no option in X for that whereas a third party plugin might provide you with better functionality and support in addition to saving some manual setup time and coding issues.

Thanks.

Hello There,

You seem to forget the login url of your site. Please add it so we can log in as we have tried the credentials in some site incorporated with your licenses and it does not work for us.

Please double check it. Thanks.

Sorry about that, secure note updated with URL and new PW

Hi Ariane,

You have added it twice that is why its not working.

Please remove the code in your child theme’s functions.php as it has already been added by your facebook pixel plugin.

Thanks

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