Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1303455
    Kamila L
    Participant

    Hi All,

    I added the facebook pixel to the child theme php but facebook isnt recognizing it. Could you please take a look and advise how to fix it?

    Thanks,
    -K

    #1303460
    Christopher
    Moderator

    Hi there,

    Please share the code and let us know how did you implement it?

    Thanks.

    #1303669
    Kamila L
    Participant
    This reply has been marked as private.
    #1303890
    Christopher
    Moderator

    Hi there,

    Please update your code to :

    
    
    // Add Facebook custom pixel Code
    // =============================================================================
    
    function add_facebook_pixel_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');
    
    fbq('init', '582376465296693'); // Insert your pixel ID here.
    fbq('track', 'PageView');
    fbq('track', 'Lead', {
    value: 10.00,
    currency: 'USD'
    });
    </script>
    
    <noscript><img height="1" width="1" style="display:none"
    src="https://www.facebook.com/tr?id=582376465296693&ev=PageView&noscript=1"
    /></noscript>
    <!– DO NOT MODIFY –>
    <!– End Facebook Pixel Code –>
    <?php 
    }
    add_action( 'wp_head', 'add_facebook_pixel_code' );
    // End Facebook custom pixel Code
    // =========================================================

    Hope it helps.

    #1304282
    Kamila L
    Participant

    Hi Christopher,

    Thanks for the above. So I want a lead conversion pixel on my thankyou page (589) and tracking pixel on page (481).

    The code on the thankyou page isnt working. How would I fix this? See my code below.

    Thanks,

    add_action( ‘x_before_site_begin’, ‘facebook_pixel_code’ );

    function facebook_pixel_code(){

    if(is_page(481) ) : ?>

    <!– 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’, ‘582376465296693’); // 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=582376465296693&ev=PageView&noscript=1&#8243;

    /></noscript>

    <!– DO NOT MODIFY –>

    <!– End Facebook Pixel Code –>

    add_action( ‘x_before_site_begin’, ‘facebook_pixel_code’ );

    function facebook_pixel_code(){

    if(is_page(589) ) : ?>

    <!– 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’, ‘582376465296693’); // Insert your pixel ID here.

    fbq(‘track’, ‘Lead’, {

    value: 10.00,

    currency: ‘USD’

    });

    </script>

    <noscript><img height=”1″ width=”1″ style=”display:none”

    src=”https://www.facebook.com/tr?id=582376465296693&ev=PageView&noscript=1&#8243;

    /></noscript>

    <!– DO NOT MODIFY –>

    <!– End Facebook Pixel Code –>

    <?php

    endif; }

    Thanks,
    -K

    #1304295
    Rue Nel
    Moderator

    Hello There,

    Thanks for updating in! If you want to display the code only for a specific page, you need to add a condition in the code. Please have your code updated and use this code instead:

    // Add Facebook custom pixel Code
    // =============================================================================
    
    function add_facebook_pixel_code(){ ?>
    
    	<?php if ( is_page(589) || is_page(481) ) : ?>
    		
    		<!– Facebook Pixel Code –>
    		add the code here
    		<!– End Facebook Pixel Code –>
    
    	<?php endif; ?>
    
    <?php }
    add_action( 'wp_head', 'add_facebook_pixel_code' );
    // End Facebook custom pixel Code
    // =========================================================

    We would loved to know if this has work for you. Thank you.

    #1305236
    Kamila L
    Participant

    Hi Rue,

    Thanks for the above so I want the lead tracking for only page 589 – fbq(‘track’, ‘Lead’, {

    value: 10.00,

    currency: ‘USD

    and I want the regular conversion tracking for only page 481.

    How would i separate the code out to account for different tracking for different pages? Hopefully this a bit clearer.

    Thanks,
    Kamila

    #1305245
    Friech
    Moderator

    Hi Kamila,

    You can remove the bit of line below on Rue’s code so it will only apply to page 589.

    || is_page(481)

    But I assume you already know that, can you confirm that your “thank you” page has an ID of 589? If so, provide us login credentials in private reply so we can take a closer look.

    Cheers!

    #1305304
    Kamila L
    Participant
    This reply has been marked as private.
    #1305321
    Lely
    Moderator

    Hello K,

    The following line might has been remove from your child theme functions.php file:
    add_filter( 'x_enqueue_parent_stylesheet', '__return_true' );
    Default content should be like this:

    <?php
    
    // =============================================================================
    // FUNCTIONS.PHP
    // -----------------------------------------------------------------------------
    // Overwrite or add your own custom functions to X in this file.
    // =============================================================================
    
    // =============================================================================
    // TABLE OF CONTENTS
    // -----------------------------------------------------------------------------
    //   01. Enqueue Parent Stylesheet
    //   02. Additional Functions
    // =============================================================================
    
    // Enqueue Parent Stylesheet
    // =============================================================================
    
    add_filter( 'x_enqueue_parent_stylesheet', '__return_true' );

    Then add the code suggested for pixel below the last line.

    Hope this helps.

    #1306233
    Kamila L
    Participant

    Hi Lely/Friech,

    Thanks that resolved the formatting issue. Can you advise on how I can put the lead tracking on page 589 only?

    fbq(‘track’, ‘Lead’, {

    value: 10.00,

    currency: ‘USD

    and Apply the base FB code to page 481 only?

    Thanks!
    -K

    #1306401
    Friech
    Moderator

    Hi Kamila,

    Unfortunately that is not possible, the base pixel should be fire first or else any events code (tracking) will not work.

    Use this code to place the base code on every page.

    // Add Facebook custom pixel Code
    // =============================================================================
    
    function add_facebook_pixel_code(){ ?>
        
    <!-- PASTE YOUR BASE PIXEL CODE HERE -->
    
    <?php }
    add_action( 'wp_head', 'add_facebook_pixel_code', 10 );
    // End Facebook custom pixel Code
    // =========================================================

    Replace the phrase <!– PASTE YOUR BASE PIXEL CODE HERE –> with your actual base code.
    Make sure there is no tracking code on the base pixel code or else it will be added on every page as well.

    And now to add the lead tracking code on page 589 only, add this code on your child theme functions.php file.

    function add_lead_tracking_code(){ ?>
    
      <?php if ( is_page(589) ) : ?>
    
        <script type="text/javascript">
        fbq('track', 'Purchase', {value: '10.00', currency:'USD'});
        </script>
    
          <?php endif; ?>
    
    <?php }
    add_action( 'wp_head', 'add_lead_tracking_code', 20 );

    Again, the tracking code will not work if there is no pixel base code above it. You can read more details about Facebook Pixel Implementation here.

    Hope it helps, Cheers!

    #1306627
    Kamila L
    Participant

    Thank You!! You guys are amazing. That worked 🙂

    #1306654
    Friech
    Moderator

    Glad we could help 🙂

    Happy New Year, Cheers!

    #1306729
    Kamila L
    Participant

    Hi Friech,

    So after a I updated the php my wordpress went blank. I am unable to access the wp-admin page. I deleted all the fb pixel code via filezilla however I am unable to access the site.

    Help Please!!

    Thanks,
    -K

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