I am attempting to implement Facebook's Ad tracking pixels for ad tracking purposes. We are required to include two trackers, 'PageView' and 'ViewContent', on the page.
This is my first experience with these scripts, and although I have written the following code, Google's Facebook Pixel Helper is showing an error message on the page:
The Facebook pixel code on this page failed to load, preventing any information from being sent to Facebook.
Could there be something incorrect in my implementation?
<script>
!function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function()
{n.callMethod? n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;
n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0;
t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window,document,'script','//connect.facebook.net/en_US/fbevents.js');
fbq('init', '123xxxxxxxxxxx');
fbq('track', 'PageView');
fbq('track', 'ViewContent', {
content_type: [contentType], //This value is dynamic and generated at runtime
content_ids: [contentId], //This value is dynamic and generated at runtime
content_name: [contentName] //This value is dynamic and generated at runtime
});
</script>