Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1401345
    Ann
    Participant

    Hey there,

    I was wondering if I can get some help with my Facebook pixel code. I have added the pixel before and I know it should go inside the function file in my child theme, but I’m a bit confused to where the event pixel should go (between <script> tags just below the </head> tag according to Facebook).

    Here’s the Facebook Pixel:

    // Add Facebook custom audience pixel Code
    // =============================================================================

    add_action(‘wp_head’,’my_tracking_pixel’);
    function my_tracking_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’, ‘1519179685044320’); // Insert your pixel ID here.
    fbq(‘track’, ‘PageView’);
    </script>
    <noscript><img height=”1″ width=”1″ style=”display:none”
    src=”https://www.facebook.com/tr?id=1519179685044320&ev=PageView&noscript=1&#8243;
    /></noscript>
    <!– DO NOT MODIFY –>
    <!– End Facebook Pixel Code –>

    <?php
    }

    // End Facebook custom audience pixel Code
    // =============================================================================

    And here’s the event pixel:

    <script>
    fbq(‘track’, ‘CompleteRegistration’, {
    value: 34.00,
    currency: ‘USD’
    });
    </script>

    And the event pixel should only be added to page-id-27850

    Thank you!

    Ann

    #1401559
    Rupok
    Member

    Hey Ann,

    You need to place the code within Child Theme’s functions.php. If you want to place the code for specific page then you need to use is_page() function – https://developer.wordpress.org/reference/functions/is_page/

    Thanks!

    #1401568
    Ann
    Participant

    Thanks Rupok!

    #1401584
    Friech
    Moderator

    You’re welcome, feel free to get in touch with us regarding any further queries about the X|Theme and Cornerstone.

    Cheers!

  • <script> jQuery(function($){ $("#no-reply-1401345 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>