Is this the plugin you are using? https://ww.wp.xz.cn/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
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.
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.
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/
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'));
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