[Resolved] Facebook pixel queries

Home Forums Support Facebook pixel queries

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #293427
    Helen

    Hi there,
    I’ve placed my base Facebook pixel code in the wp_head section in GP Hooks. Does the execute PHP box need to be ticked?

    I expect that the above will post the pixel code to every page, but is there also a way to post a different pixel code to a specific page, for example a custom event pixel for sign-up page?
    Many thanks for your help,
    Helen
    ps – Happy St Patrick’s Day from Ireland!

    GP Premium 1.2.96
    #293430
    Leo
    Staff
    Customer Support

    Hi Helen,

    Can you share the code you used on here?

    Thanks.

    #293484
    Tom
    Lead Developer
    Lead Developer

    Happy St Patrick’s Day! 🙂

    If you need it to show up on specific pages, you would need to use PHP.

    For example:

    <?php if ( is_page( 'my-page-slug' ) ) { ?>
        Your FB pixel code for yourwebsite.com/my-page-slug
    <?php } ?>
    #293791
    Helen

    Many thanks for your replies. The code I’ve placed in wp_head is below, it was copied from Facebook’s pixel helper and is for my basic pixel.

    <!– 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’, ‘123mypixelcode’); // Insert your pixel ID here.
    fbq(‘track’, ‘PageView’);
    </script>

    If I want to add a specific pixel to a single page I would add Tom’s code underneath and tick the execute pho box, is that correct?

    So my code in wp_head is now:

    <!– 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’, ‘123mypixelcode’); // Insert your pixel ID here.
    fbq(‘track’, ‘PageView’);
    </script>

    <?php if ( is_page( ‘my-page-slug’ ) ) { ?>
    Your FB pixel code for yourwebsite.com/my-page-slug
    <?php } ?>

    Is that correct?

    Many thanks indeed for your help,
    Kind regards,
    Helen

    #293804
    Leo
    Staff
    Customer Support

    Hi Helen,

    You would first want to replace the “Your FB pixel code for yourwebsite.com/my-page-slug” from Tom with the actual facebook code (from <script> to </script>).

    Then replace “my-page-slug” with the actual page slug that you want to apply the facebook setting.

    Let us know if this is clear.

    #293901
    Tom
    Lead Developer
    Lead Developer

    It might be easier to use a plugin: https://en-ca.wordpress.org/plugins/oh-add-script-header-footer/

    This way you can just add your FB code onto the pages you want it to appear 🙂

    #293942
    Helen

    Thanks Leo and Tom,
    That’s very clear and helpful. I’ll try both ways and post here again if I can’t get one of them going.
    Cheers,
    Helen

    #294036
    Leo
    Staff
    Customer Support
Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.