Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook Conversion Pixel code: BODY vs HEAD

Can I place the Facebook Conversion Pixel inside the BODY (as opposed to inside the HEAD, which is what Facebook suggest in their specs?

I don't see why not. Has anybody tried it?

Here is an example of the code

<script type="text/javascript">         var fb_param = {};         fb_param.pixel_id = '123456789';         fb_param.value = '10';         fb_param.currency = 'USD';         (function(){             var fpw = document.createElement('script');             fpw.async = true;             fpw.src = '//connect.facebook.net/en_US/fp.js';             var ref = document.getElementsByTagName('script')[0];             ref.parentNode.insertBefore(fpw, ref);         })();     </script>     <noscript><img height="1" width="1" alt="" style="display:none" src="https://www.facebook.com/offsite_event.php?id=1234566&amp;value=10&amp;currency=USD" /></noscript> 
like image 823
cockypup Avatar asked Jan 29 '14 19:01

cockypup


People also ask

Does Facebook pixel go in head or body?

It works in the BODY.

Can I put Facebook pixel in footer?

Go to Settings → Insert Headers and Footers. Paste the Facebook Pixel tracking code into the Scripts in Header box. Save your changes.

Where is the Facebook pixel header code?

Log into Facebook in a web browser on your laptop or desktop. 'Create Pixel' screen will appear if you have not already done so. Pixel code will be in upper right corner if you have created one.

What are Facebook conversion pixels?

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.


1 Answers

According to this answer here: https://www.facebook.com/help/community/question/?id=10200354561858276

you can place it inside the <BODY> element but FB recommends to keep it at the beginning of <BODY> or in the <HEAD> as the conversion will be then counted even if the page does not load fully or the user closes the page.

like image 67
Michal Trojanowski Avatar answered Sep 28 '22 10:09

Michal Trojanowski