Title: Facebook pixel amp errors
Last modified: February 4, 2019

---

# Facebook pixel amp errors

 *  Resolved [rsmith4321](https://wordpress.org/support/users/rsmith4321/)
 * (@rsmith4321)
 * [7 years, 3 months ago](https://wordpress.org/support/topic/facebook-pixel-amp-errors/)
 * If I add the official Facebook pixel plugin, the facebook pixel code is added
   on amp pages and causes errors. I’m using paired mode. Is there a way to strip
   the facebook pixel code from the amp pages or disable that plugin on amp? How
   do you recommend adding Facebook Pixel code in wordpress so it doesn’t make amp
   pages fail verification? Thanks.
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Ffacebook-pixel-amp-errors%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

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

 *  Plugin Author [Weston Ruter](https://wordpress.org/support/users/westonruter/)
 * (@westonruter)
 * [7 years, 3 months ago](https://wordpress.org/support/topic/facebook-pixel-amp-errors/#post-11168258)
 * Is this the plugin you are using? [https://wordpress.org/plugins/official-facebook-pixel/](https://wordpress.org/plugins/official-facebook-pixel/)
 * I checked the AMP validator and I see no errors: [https://validator.ampproject.org/#url=https%3A%2F%2Fwww.ryansmithphotography.com%2Fblog%2F2019%2F01%2F30%2Fbridal-portraits-pawleys-plantation-golf-club%2F%3Famp](https://validator.ampproject.org/#url=https%3A%2F%2Fwww.ryansmithphotography.com%2Fblog%2F2019%2F01%2F30%2Fbridal-portraits-pawleys-plantation-golf-club%2F%3Famp)
 * Are you referring to the internal validation errors in the admin? Is the one 
   for the Facebook Pixel being flagged along with the status “new accepted”?
 * Please share the full details of the validation error. If you can accept it once
   and then stays accepted, then that is the easiest solution for you. Otherwise,
   if the pixel validation error changes with each request, then am alternative 
   would be needed.
 *  Thread Starter [rsmith4321](https://wordpress.org/support/users/rsmith4321/)
 * (@rsmith4321)
 * [7 years, 3 months ago](https://wordpress.org/support/topic/facebook-pixel-amp-errors/#post-11168423)
 * Thanks for the reply. Yes that is the plugin, there are no errors currently because
   I deactivated it. It causes a number of validation errors on amp pages when the
   plugin is activated that are not stripped by your amp plugin like most other 
   errors are. It seems like it is completely bypassing your sanitation of the amp
   pages and loads iframes and other incompatible code. Actually this happens if
   I just add the Facebook pixel code in manually as well and not through the plugin.
 *  Plugin Author [Weston Ruter](https://wordpress.org/support/users/westonruter/)
 * (@westonruter)
 * [7 years, 3 months ago](https://wordpress.org/support/topic/facebook-pixel-amp-errors/#post-11168435)
 * Please re-activate the plugin and copy the page source when the validation errors
   are present. You can then share the page source via a site like [https://gist.github.com/](https://gist.github.com/)
 *  Thread Starter [rsmith4321](https://wordpress.org/support/users/rsmith4321/)
 * (@rsmith4321)
 * [7 years, 3 months ago](https://wordpress.org/support/topic/facebook-pixel-amp-errors/#post-11168528)
 * Ok here you go [https://gist.github.com/rsmith4321/f9ae444751f8670856b0e95c03246294](https://gist.github.com/rsmith4321/f9ae444751f8670856b0e95c03246294)
 *  Plugin Author [Weston Ruter](https://wordpress.org/support/users/westonruter/)
 * (@westonruter)
 * [7 years, 3 months ago](https://wordpress.org/support/topic/facebook-pixel-amp-errors/#post-11168672)
 * OK, this is the offending markup:
 *     ```
       <!-- Facebook Pixel Code --><!--noscript-->
       <amp-img height="1" width="1" alt="fbpx" src="https://www.facebook.com/tr?id=326917374346566&ev=PageView&noscript=1" class="amp-wp-enforced-sizes amp-wp-cb45893" layout="intrinsic"></amp-img><!--/noscript--><!-- End Facebook Pixel Code -->
       ```
   
 * So in the non-AMP version of the page, there is likely this being added to the
   head:
 * `<noscript><img height="1" width="1" alt="fbpx" src="https://www.facebook.com/
   tr?id=326917374346566&ev=PageView&noscript=1"></noscript>`
 * This is getting unwrapped and converted into `amp-img` in AMP. In any case, it
   is not correct to have this in the `head`, so the plugin isn’t adding this in
   the right spot.
 * Indeed, I can see the `\FacebookPixelPlugin\Core\FacebookWordpressPixelInjection::
   injectPixelNoscriptCode()` function is getting added at `wp_head` as opposed 
   to `wp_footer`, which it should be doing.
 * You can find this in `core/FacebookWordpressPixelInjection.php`.
 * I suggest contacting the plugin’s maintainer and requesting they change:
 *     ```
             add_action(
               'wp_head',
               array($this, 'injectPixelNoscriptCode'));
       ```
   
 * Into:
 *     ```
             add_action(
               'wp_footer',
               array($this, 'injectPixelNoscriptCode'));
       ```
   
 *  Thread Starter [rsmith4321](https://wordpress.org/support/users/rsmith4321/)
 * (@rsmith4321)
 * [7 years, 3 months ago](https://wordpress.org/support/topic/facebook-pixel-amp-errors/#post-11168884)
 * The developer is Facebook so it might be something you would want to work with
   them officially on. What I did is I just added the Facebook pixel code in manually.
   I had tried adding it to the wp_head before and had the same problems but based
   on your suggestion I added it to wp_footer now and it seems to fix the amp issues.
   You can view it here [https://www.ryansmithphotography.com/?amp](https://www.ryansmithphotography.com/?amp)
 *  Plugin Author [Weston Ruter](https://wordpress.org/support/users/westonruter/)
 * (@westonruter)
 * [7 years, 3 months ago](https://wordpress.org/support/topic/facebook-pixel-amp-errors/#post-11168934)
 * I suggest you leave a message on their support forum: [https://wordpress.org/support/plugin/official-facebook-pixel/](https://wordpress.org/support/plugin/official-facebook-pixel/)

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

The topic ‘Facebook pixel amp errors’ is closed to new replies.

 * ![](https://ps.w.org/amp/assets/icon.svg?rev=2527602)
 * [AMP](https://wordpress.org/plugins/amp/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/amp/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/amp/)
 * [Active Topics](https://wordpress.org/support/plugin/amp/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/amp/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/amp/reviews/)

 * 7 replies
 * 2 participants
 * Last reply from: [Weston Ruter](https://wordpress.org/support/users/westonruter/)
 * Last activity: [7 years, 3 months ago](https://wordpress.org/support/topic/facebook-pixel-amp-errors/#post-11168934)
 * Status: resolved