Copy the base code and paste it between the <head> tags on each web page, or in your website template to install it on your entire website
Events are actions that happen on your website, either as a result of Facebook ads (paid) or organic reach (unpaid). The event code lets you track those actions and leverage them in advertising.
There are two types of events you can send:
Standard events: 9 events we’re able to track and optimize your ads for without any additional actions. See below for an example of what your website code will look like with standard events installed.
1. Your website’s original code: Paste the Facebook pixel code between the <head> and </head> tags of your web page. You may already have other existing code between the head tags, so just place the pixel code underneath that, but above </head>.
2. Your Facebook pixel base code: Your Facebook pixel code will look like the diagram above, except your pixel ID will be different from 1234567890.
3. Your standard event code: Within your Facebook pixel code, above the </script> tag, paste the Standard Event code that’s relevant to your page (ex: Complete Registration, Add To Cart). You’ll need to do this for every page you want to track.
The key here is that every page of your website should have everything that’s enclosed in section 2 (the base code), but different pages will have different snippets of code for section 3 (standard event code). See below for another example.
Custom events. Actions that are important to your business, but that you can’t use for tracking and optimization without additional action.
Adding the event code to your website’s pages
Event code indicates specific actions that are important to your business objective. To add the event code to your website:
Click Create Conversion > Track Conversions with Standard Events.
Copy the Event Code of the events that matter to you.
Go to your website’s code and place the event code on the relevant pages. We recommend doing this by adding the event code between script tags separately. We recommend not modifying the pixel base code.
Tips: Add a full funnel of events (ex: ViewContent, AddToCart and Purchase) to capture all relevant purchase actions.
On the special pages of your website that you want to track and optimize your ads for, add one of these 9 standard events. For example, someone selling toys on their website would place standard event codes for their add-to-cart page and purchase page. Just copy and paste everything in the standard event code column and paste it under fbq(‘track’,’PageView’); like in the diagram above. If you’d prefer to use URL rules instead of standard events, you can use custom conversions instead.
Note: You can also add different parameters for each standard event code, such as Content ID, value and currency. The conversion standard event requires value and currency parameters to work. Parameters are optional for all other standard events.