Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1386486
    Hello
    Participant

    Hi,
    Please could you help add code to dynamically pass values for purchases on Woocommerce in WordPress with a Facebook Pixel code.

    The code is part of a Standard Event in Facebook called “Make purchase” and is:

    fbq(‘track’, ‘Purchase’, {value: ‘0.00’, currency: ‘GBP’});

    But I need to code to be dynamic. So could you help dynamically pass the value of the purchase in place of the 0.00 in the “value: 0.00” portion of the purchase event.

    This is the purchase variable I have been given for Woocommerce:

    <?php echo $order->get_order_total(); ?>

    These pages have all the information.

    https://www.facebook.com/business/help/402791146561655?helpref=faq_content

    https://www.facebook.com/business/help/392174274295227?helpref=faq_content

    https://developers.facebook.com/docs/facebook-pixel/pixel-with-ads/conversion-tracking

    https://andrewhubbard.co/complete-guide-facebook-conversion-tracking/

    It’s the dynamic passing with replacing the value with a variable that I need help with. First to make sure the variable is correct and second how to install the standard event code and the pixel base code in the order received page in Woocommerce.

    Facebook says they should be in the global header template (which I presume is the global header.php).

    I didn’t install the base code here originally as Facebook advised to use the Insert Headers and Footer plug in in Settings, which I did to install the base code.

    https://www.facebook.com/business/help/457075141160886

    But that plug in only allows code INSIDE the header tags. And Facebook says the standard event code must be outside the tags. Please refer to the follow up message I sent.

    So, this doesn’t give me much choice except to add the code to the global header.php file instead of using the plug in. So, once added I will remove the base code from the plugin.

    So, should I copy the global header.php file to my child theme and edit from there?

    There is confusion here as the last link above says to install it in between the head tags but Facebook says to install it outside. Please help clarify.

    According to the last link, I have to dynamically pass the currency as well? Is this right? Facebook doesn’t mention it.

    The page I need to add the code to is the “Thank You” or order confirmation page in Woocommerce.

    https://trillionpeak.com/checkout/order-received/

    I know this is a lot here to go through but please could you give detailed step by step instructions on how to deal with this.

    Thank you.

    #1386487
    Hello
    Participant
    This reply has been marked as private.
    #1386752
    Rad
    Moderator
    This reply has been marked as private.
  • <script> jQuery(function($){ $("#no-reply-1386486 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>