Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1304108
    s_mocko
    Participant

    Hi,

    I am trying to set up a custom add to cart facebook pixel. But when I do an add to cart there is no link to enter for facebook to track.

    What would the link be to to track when someone adds to cart?

    Eurekawellness.com.au

    Thanks

    #1304123
    s_mocko
    Participant

    To clarify,

    I have the ajax add to cart. So when someone click add to cart button it stays on the same page. Is there a code I put in functions.php that would track everytime someone clicked the add to cart button?

    Thanks

    #1304227
    s_mocko
    Participant

    Merry Christmas BTW. Awesome team

    #1304255
    Lely
    Moderator

    Hello There,

    Merry Christmas to you and your family as well. This is how we add facebook pixel code:

    // Add scripts to wp_head()
    function head_scripts() { ?>
        <!-- Your FB Pixel Script goes here -->
    <?php }
    add_action( 'wp_head', 'head_scripts' );

    We have to add the code on your child theme’s functions.php file.
    Can you give us the code you were using so we can check?

    #1306290
    s_mocko
    Participant

    Hi this is the pixel code I have been using.

    <!– 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’, ‘925342327542740’); // 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=925342327542740&ev=PageView&noscript=1&#8243;
    /></noscript>
    <!– DO NOT MODIFY –>
    <!– End Facebook Pixel Code –>

    I was not using the old pixel.

    #1306294
    s_mocko
    Participant

    Oh, this is what was in the functions.php in the child folder

    // 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’,’//connect.facebook.net/en_US/fbevents.js’);

    fbq(‘init’, ‘925342327542740’);
    fbq(‘track’, “PageView”);</script>
    <noscript><img height=”1″ width=”1″ style=”display:none”
    src=”https://www.facebook.com/tr?id=925342327542740&ev=PageView&noscript=1&#8243;
    /></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

    #1306295
    s_mocko
    Participant
    // 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','//connect.facebook.net/en_US/fbevents.js');
    
    fbq('init', '925342327542740');
    fbq('track', "PageView");</script>
    <noscript><img height="1" width="1" style="display:none"
    src="https://www.facebook.com/tr?id=925342327542740&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
    #1306653
    Friech
    Moderator

    Hi There,

    Please update your code to this:

    // Add Facebook custom audience pixel Code
    // =============================================================================
    function add_facebook_audience_pixel_code(){
    ?>
    
    <!-- Facebook Base 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','//connect.facebook.net/en_US/fbevents.js');
    
    fbq('init', '925342327542740');
    fbq('track', "PageView");</script>
    <noscript><img height="1" width="1" style="display:none"
    src="https://www.facebook.com/tr?id=925342327542740&ev=PageView&noscript=1"
    /></noscript>
    <!-- End Facebook Base Pixel Code -->
    
    <!-- Tracking AddToCart Code -->
        <script type="text/javascript">
          fbq('track', 'AddToCart');
        </script>
    <!-- End Tracking AddToCart Code -->
    
    <?php 
    }
    add_action( 'wp_head', 'add_facebook_audience_pixel_code' );
    

    Let us know how it goes.

    Cheers!

    #1306788
    s_mocko
    Participant

    Hi,

    Does this track standard event? Such as where do I place the standard event code in the website page at? Do I have to use a plugin for this?
    Also the woocommerce page after checkout is the checkout page. How would you add the event code to this page so it fires only after order is taken and paid?

    Is there a plugin you recommend that works with X for this?

    #1306818
    Lely
    Moderator

    Hello There,

    The code will just be added on your site on every page. But then it depends on your tracking code how it will works and which event it will fire. I found the following plugins that might help:

    https://wordpress.org/plugins/pixelyoursite/
    https://wordpress.org/plugins/facebook-conversion-pixel/

    Please just note that questions regarding integration should be forwarded to plugin developers.

    Cheers!

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