[Resolved] Facebook Pixel Questions

Home Forums Support [Resolved] Facebook Pixel Questions

Home Forums Support Facebook Pixel Questions

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #390274
    Dave

    Hi Tom,

    I have the following FB Pixel that is supposed to appear on every page so I put it in the wp_head hook. Here is that code:
    —————————–
    <!– Facebook Pixel Code –>
    <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’,
    https://connect.facebook.net/en_US/fbevents.js&#8217;;);
    fbq(‘init’, ‘172080303350186’);
    fbq(‘track’, ‘PageView’);
    </script>
    <noscript><img height=”1″ width=”1″ style=”display:none”
    src=”https://www.facebook.com/tr?id=172080303350186&ev=PageView&noscript=1&#8243;;
    /></noscript>

    <!– End Facebook Pixel Code –>
    ———————————————
    Now I’m supposed to put a Facebook Pixel Code on the Landing page that I built to show that the content was viewed. Here is that code:
    ———————————–
    <!– Facebook Pixel Code –>
    <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’,
    https://connect.facebook.net/en_US/fbevents.js&#8217;;);
    fbq(‘init’, ‘172080303350186’);
    fbq(‘track’, ‘PageView’);

    fbq(‘track’, ‘ViewContent’);

    </script>
    <noscript><img height=”1″ width=”1″ style=”display:none”
    src=”https://www.facebook.com/tr?id=172080303350186&ev=PageView&noscript=1&#8243;;
    /></noscript>
    <!– End Facebook Pixel Code –>
    ———————————————
    The only change is the insertion of this code – fbq(‘track’, ‘ViewContent’); –

    I’m also supposed to insert the pixel again on the ‘Thank You’ page that I built so that I can tell if the conversion took place. In this case I replace the – fbq(‘track’, ‘ViewContent’);- with – fbq(‘track’, ‘Lead’); –

    So these fire individually on each page. Do you have any idea where I should put the second two scripts?

    I don’t know if the go below the first script in the wp_head tag or in one of the other hooks.

    Thanks for you help!

    #390342
    Leo
    Staff
    Customer Support

    Hi there,

    Yup that can all go into wp_head

    We will need to wrap them in conditional tags so they are only on certain pages though.

    For front page:

    <?php if ( is_front_page() ) : ?>
        code here
    <?php endif; ?>

    For thank you page:

    <?php if ( is_page( 'your-page' ) ) { ?>
        code here
    <?php } ?>

    Make sure execute PHP is checked.

    #390362
    Tom
    Lead Developer
    Lead Developer

    Should work perfectly.

    You can confirm the pixel is working by following the instructions on this page: https://www.facebook.com/business/help/952192354843755

    #4 – Make sure your pixel’s working correctly

    #390582
    Dave

    Hi Tom & Leo,

    I’m really struggling with this. Here is the code I inserted in the wp_head hook, and clicked the box to Execute PHP

    Here is the complete script copied directly from wp_head:

    <!– Facebook Pixel Code –>
    <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’,
    https://connect.facebook.net/en_US/fbevents.js&#8217;);
    fbq(‘init’, ‘172080303350186’);
    fbq(‘track’, ‘PageView’);
    </script>
    <noscript>
    <img height=”1″ width=”1″
    src=”https://www.facebook.com/tr?id=172080303350186&ev=PageView
    &noscript=1″/>
    </noscript>
    <!– End Facebook Pixel Code –>

    <?php if ( is_front_page() ) : ?>
    <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’,
    https://connect.facebook.net/en_US/fbevents.js&#8217;;;);
    fbq(‘init’, ‘172080303350186’);
    fbq(‘track’, ‘PageView’);
    fbq(‘track’, ‘ViewContent’);
    </script>
    <noscript><img height=”1″ width=”1″ style=”display:none”
    src=”https://www.facebook.com/tr?id=172080303350186&ev=PageView&noscript=1&#8243;;;
    /></noscript>
    <!– End Facebook Pixel Code –>
    <?php endif; ?>

    <?php if ( is_page( ‘thank-you’ ) ) { ?>
    <!– Facebook Pixel Code –>
    <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’,
    https://connect.facebook.net/en_US/fbevents.js&#8217;;;);
    fbq(‘init’, ‘172080303350186’);
    fbq(‘track’, ‘PageView’);
    fbq(‘track’, ‘Lead’);
    </script>
    <noscript><img height=”1″ width=”1″ style=”display:none”
    src=”https://www.facebook.com/tr?id=172080303350186&ev=PageView&noscript=1&#8243;;;
    /></noscript>
    <!– End Facebook Pixel Code –>
    <?php } ?>

    When I check it with the Chrome pixel helper, the first ‘Pageview’ code fires. However the conditional pixels for (is_front_page() and ( is_page( ‘thank-you’ ) ), gives me this error.

    -The Facebook pixel code on this page didn’t load, therefore no information was sent to facebook –

    I’m pretty sure I followed the instructions as described but I can’t seem to isolate the problem.

    The URL’s are:

    https://www.bestlocalroofing.com/

    https://www.bestlocalroofing.com/thank-you/

    I don’t know if you can test on your end or see anything, I can also give you a login to the site. I am using Thrive Architect to build these, but I don’t think that should matter for this.

    Any help is appreciated!

    Dave ~

    #390798
    Tom
    Lead Developer
    Lead Developer

    Hi Dave,

    Are you trying a different method now? Your code looks different than what you shared in here earlier.

    Let me know ๐Ÿ™‚

    #390809
    Dave

    Tom,

    Sorry. I think that there’s a conflict with Thrive Architect which is a page builder for developing sales funnels. It’s the WordPress alternative to ClickFunnels which I absolutely hate. I’m using Thrive Architect on this particular project with your theme. From what I can tell from their documentation, if you use it to building a landing page their custom script area settings on the landing page nullifies wp_head code in the theme script for that page.

    I don’t know for sure as their support is very slow. I ended up using:

    https://wordpress.org/plugins/pixel-caffeine/

    It’s a free plugin and I was done in 5 minutes after trying to figure out where the problem was for hours. I should have updated this ticket so you guys didn’t spend more time on it. I’ll eventually get an answer from their support, but this was the solution for me right now as I needed to get a Facebook ad campaign going for a client.

    Thanks for a great product and great support.

    Dave ~

    #390842
    Tom
    Lead Developer
    Lead Developer

    No problem! Glad you got something working for now ๐Ÿ™‚

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.