I'm adding a Facebook tracking script for a client and noticed that the instructions say to add a section of the code just below the closing head tag (before the body). However standard practice suggests that all scripts should be loaded at the end of the body, while tracking code like Google Analytics suggests that you add them in the head so it triggers right away. What effect does adding a script between the head and body tags have (page load, data collection, etc.), and why does Facebook specifically just want the event code outside of the head tag? How is it different from adding it as the last item in the head tag?
Instructions (not sure if any part of the initiation script contains data specific to my client, so blurring the whole thing for privacy):
Event codes are additional pieces of code you can add under the default pixel code to specific pages of your website that allow you to track certain actions on those pages.
The Facebook pixel is a piece of code that you place on your website. It collects data that helps you track conversions from Facebook ads, optimize ads, build targeted audiences for future ads and remarket to people who have already taken some kind of action on your website.
Once your Facebook pixel is installed, you’ll want to adjust your ads manager and pixel settings to track the actions that make sense for your business and website. You can do this when you install the pixel, or edit your events tracking later in the ads manager’s settings. There are 17 standard events that you can track via your Facebook pixel.
When a customer takes action on your website, the Facebook pixel code is triggered and reports their actions. The report of your Facebook pixel activity can be found in Facebook’s ads manager.
To create a custom Facebook pixel event, go to your Facebook Events Manager under the Measure & Report tab. Click “Create Custom Conversion” and then set the parameters for how this conversion can be measured using URL rules. To ensure that your Facebook pixel is installed correctly, you can use the Facebook pixel helper.
Without the Facebook pixel, you cannot track conversions on your Facebook ads, only other metrics like engagement, reach, and link clicks. Conversions tell you more about your website visitors’ actions, revealing what they click and their customer journey on your site.
that's a typo. See Facebook Pixel Implementation Guide
Your website's original code: Paste the Facebook pixel code between the <head> and </head>1 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>.
1 Bold added by me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With