Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1407043

    Itwebdevelopment
    Participant

    Hi, I need to install a facebook pixel. Wondering if you can help me do this with this theme.

    Here’s what they say to do:

    https://gyazo.com/5ab4df7e3439d0a17042ba1e34da0c91

    #1407046

    Itwebdevelopment
    Participant
    This reply has been marked as private.
    #1407567

    Rupok
    Member

    Hi there,

    Thanks for writing in! You can follow this thread – https://community.theme.co/forums/topic/facebook-pixel-code/#post-825188

    If you search on our forum before posting, you might get the answer quickly. If you don’t get the right answer, we are always here but give it a try first.

    Cheers!

    #1407634

    Itwebdevelopment
    Participant
    This reply has been marked as private.
    #1407759

    Thai
    Moderator

    Hi There,

    Would you mind providing us with login credentials so we can take a closer look? To do this, you can make a post with the following info:

    – Link to your site
    – WordPress Admin username / password
    – FTP credentials

    Don’t forget to select Set as private reply. This ensures your information is only visible to our staff.

    Thanks.

    #1408625

    Itwebdevelopment
    Participant
    This reply has been marked as private.
    #1409126

    Rupok
    Member

    Hi there,

    Your FTP credentials not working, maybe the FTP server is not correct. Hoerver if you check the source code, you will see the script has been added properly. So the code is doing what it supposed to do, no further check required. If the code is fine, it should work fine.

    Cheers!

    #1412597

    Itwebdevelopment
    Participant

    Well.. It’s not working fine in fact it’s not showing on facebook at all lol

    #1413157

    Rue Nel
    Moderator

    Hello There,

    Thanks for updating in! I have inspected the code and it turns out that the single quotes in the script is invalid. I already corrected it to save you some time. I changed the code to this:

    // Add Facebook custom audience pixel Code
    // =============================================================================
    function add_facebook_audience_pixel_code(){
    ?>
    
    <!– Insert Facebook custom audience pixel Code starts here –>
    
    <!– 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', '1724215121128079');
    fbq('track', "PageView");</script>
    <noscript><img height="1" width="1" style="display:none"
    src="https://www.facebook.com/tr?id=1724215121128079&ev=PageView&noscript=1"
    /></noscript>
    <!– End Facebook Pixel Code –>
    
    <!– Insert Facebook custom audience pixel Code Code ends here –>
    
    <?php
    }
    add_action( 'wp_head', 'add_facebook_audience_pixel_code' );
    // End Facebook custom audience pixel Code
    // =============================================================================
    

    Please check your site in with the Facebook Pixel now.

    #1413198

    Itwebdevelopment
    Participant
    This reply has been marked as private.
    #1413643

    Lely
    Moderator

    Hi There,

    Yes, it is correct.

    Please update above code for pixel on functions.php to this:

    // Add Facebook custom audience pixel Code
    // =============================================================================
    function add_facebook_audience_pixel_code(){
    ?>
    
    <!– Insert Facebook custom audience pixel Code starts here –>
    <!– 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', '780113285485611');
    fbq('track', "PageView");</script>
    <noscript><img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=780113285485611&ev=PageView&noscript=1"/></noscript>
    <!– End Facebook Pixel Code –>
    <!– Insert Facebook custom audience pixel Code Code ends here –>
    
    <?php
    // For BLOG
    if(is_home()){
    ?>
    <script>
    fbq('track', 'ViewContent');
    </script>
    <?php
    }
    
    // For CHECKOUT
    if(is_checkout()){
    ?>
    <script>
    fbq('track', 'InitiateCheckout');
    </script>
    <?php
    }
    
    // For PURCHASE
    if(is_wc_endpoint_url()){
    ?>
    <script>
    fbq('track', 'Purchase');
    </script>
    <?php
    }
    
    // For COnvertplug
    if(is_page('1')){
    ?>
    <script>
    fbq('track', 'CompleteRegistration');
    </script>
    <?php
    }
    
    } //function closing
    add_action( 'wp_head', 'add_facebook_audience_pixel_code' );
    // End Facebook custom audience pixel Code
    // =============================================================================

    For Convertplug, look for this line: if(is_page('1')){ change 1 to your convertplug thank you page ID.

    For add to cart, add the following code on Appearance > Customize > Custom > Edit Global JS:

    jQuery('.add_to_cart_button').on('click',  function() {
    
    fbq('track', 'AddToCart');
    
    } );

    Hope this helps.

    #1414233

    Itwebdevelopment
    Participant

    Hi, it’s telling me that my add to cart trigger isn’t going and I’m not seeing any other triggers on facebook. Could you take a look?

    Thanks!

    #1414910

    Rad
    Moderator
    This reply has been marked as private.