The Facebook Pixel allows you to track, measure, and analyze user actions on your site and then be able to use this information to reach customers again in future Facebook ads. To make use of it, you’ll need to first create the Pixel in your Facebook Events Manager by following the official Facebook instructions to manually add pixel code. Once you have the code, you are ready to paste it into your site.
Note: You can also choose to use one of Facebook’s Pixel Partner Integrations such as its WooCommerce integration if you prefer. This document does not address that method since there are many integrations to choose from, and Facebook has documented each of them. The following directions are only for the manual method of adding the code.
Facebook Pixel code should be placed in the <head> section of your site’s pages. This is outside of the area in which Elementor has any influence, so you won’t be using Elementor for this process. You’ll need to paste the code supplied to you at the bottom of the theme’s head section, just above the closing </head> tag.
There are two basic ways to add this code.
Method 1 (more technical): Edit Your Child Theme’s header.php Code
Simply paste the code that you obtain from Facebook into the header.php of your child theme.
Warning: Never update your core / parent theme code, as anything you change will be deleted during the next theme update. Always use a child theme if you plan to edit any of the code.
Method 2 (easiest): Use A WordPress Plugin To Manage Code
Instead of using a child theme, you can install a plugin such as Insert Headers and Footers, which allows you to insert code into the header or footer of any theme you are using. This is a quick and simple way to insert Facebook Pixel code as well as other scripts such as Google Analytics, etc. Simply install the plugin and paste the Facebook Pixel script into the header script box. This method places the Facebook Pixel code on all pages of your site.
In some cases, you may need more precise control over where the code is placed. In that case, you should install a plugin dedicated to handling all the various Facebook Pixel options such as Pixel Cat instead of installing Insert Headers and Footers plugin. The Pixel Cat plugin has many features and is best for more advanced use cases such as tracking custom events. See Pixel Cat’s Getting Started Guide for more information on setting the plugin’s options.