Search code examples
javascriptfacebookfacebook-pixel

Multiple Facebook trackers on page generating errors


I am trying to use Facebook's Ad tracking pixels to track ads. We need to have two trackers on Page 'PageView' and 'ViewContent' .

This is my first time using these scripts, I have written following code but Google's Facebook Pixel Helper is generating this error on page:

The Facebook pixel code on this page didn't load, so no information was sent to Facebook.

Am I doing anything wrong?

                    <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, genrated at runtime
                content_ids: [contentId], //This value is dynamic, genrated at runtime
                content_name: [contentName]  //This value is dynamic, genrated at runtime

                });
                </script>

Solution

  • Issue is resolved.

    I was not putting square brackets around [contentId], thought they were there in example, just to indicate that 'contentId' is a dynamic value.Silly me!

    Thanks everyone who replied.