Title: Error adding FB Pixel to functions.php
Last modified: August 13, 2017

---

# Error adding FB Pixel to functions.php

 *  Resolved [jlcule](https://wordpress.org/support/users/qlbras/)
 * (@qlbras)
 * [8 years, 9 months ago](https://wordpress.org/support/topic/error-adding-fb-pixel-to-functions-php/)
 * I am trying to add the Facebook Pixel code to the functions.php of my child theme.
   I don’t know anything about PHP, so I followed the instructions of this page 
   [https://www.tipsandtricks-hq.com/how-to-advertise-to-your-wordpress-visitors-from-facebook-8340](https://www.tipsandtricks-hq.com/how-to-advertise-to-your-wordpress-visitors-from-facebook-8340)
 * The problem is that the pixel does not work: it does not load (I am using the
   Facebook Pixel Helper extension for Chrome). I don’t know anything about PHP,
   so I think I did not implement the code well. The functions.php of my child theme
   has a code for Google Analytics too, so I don’t know if it’s a problem too. I
   made a screenshot of the content of my functions.php file: [http://imgur.com/a/rZwUW](http://imgur.com/a/rZwUW)
 * I know I can add both tracking codes to the header.php of my child theme, but
   the Admin Control Panel of WordPress does not give me access and, as I am using
   a child theme, I prefer add the code to functions.php.
 * Thanks.
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Ferror-adding-fb-pixel-to-functions-php%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [8 years, 9 months ago](https://wordpress.org/support/topic/error-adding-fb-pixel-to-functions-php/#post-9406247)
 * The FB code is appearing correctly on your site’s home page, so you’ve done everything
   correctly as far as PHP is concerned. External code like this can conflict with
   other code and is nearly impossible to debug because the external code is all
   minified.
 * One thing to try is hooking “wp_footer” instead of “wp_head”. This causes the
   script output to appear closer to the closing </body> tag, which sometimes is
   thought to help. If you add your hook with a large priority number, there’s a
   good chance your code will be the last script listed on the page.
 * Another thing to try is to remove the FB script portion and remove the <noscript
   > tags so only the web pixel is output, no javascript at all. This is the fallback
   method should a visitor have javascript disabled. You would be enabling it for
   all visitors. It will not conflict with other script on your page. Pixel helper
   may complain, but it should work in FB itself.
 * FYI, when posting code as reference in these forums, it’s much preferred you 
   post usable text in a site like [Pastebin](http://pastebin.com) or [Gist](https://gist.github.com).
   Images of code are not useful should your code need to be tested or used in corrected
   examples.
 *  Thread Starter [jlcule](https://wordpress.org/support/users/qlbras/)
 * (@qlbras)
 * [8 years, 9 months ago](https://wordpress.org/support/topic/error-adding-fb-pixel-to-functions-php/#post-9421712)
 * Hi bcworkz.
 * Thanks for the answer. I waited 4 days and finally, Facebook detects its pixel
   implemented correctly. I did not change anything. Looks like Facebook needs more
   time than Analytics to check its pixel.
 * Anyway, thanks!
    -  This reply was modified 8 years, 9 months ago by [jlcule](https://wordpress.org/support/users/qlbras/).
 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [8 years, 9 months ago](https://wordpress.org/support/topic/error-adding-fb-pixel-to-functions-php/#post-9422180)
 * You’re welcome. 4 days!! That’s good to know in itself. This topic would likely
   help others, thanks for reporting back.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Error adding FB Pixel to functions.php’ is closed to new replies.

## Tags

 * [functions](https://wordpress.org/support/topic-tag/functions/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 2 participants
 * Last reply from: [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * Last activity: [8 years, 9 months ago](https://wordpress.org/support/topic/error-adding-fb-pixel-to-functions-php/#post-9422180)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
