Results 1 to 5 of 5
  1. #1
    Join Date
    Nov 2019
    Posts
    1
    Plugin Contributions
    0

    Default Need helping finding variable for order total when used with Facebook Pixel

    Hello, I'm attempting to setup the Purchase event with our Facebook Pixel on our Zen Cart site and I'm having trouble getting it to push the value through.

    I've tried a variety of different variables for order total, even the one supplied by Zen Cart on this page, specially "<?php echo $order_summary['order_total']; ?>" and it hasn't worked, regardless of what I try.

    The example for the code is below. This would only be on our checkout page to indicate a successful transaction has taken place and it would send the value of the order to the Facebook Ad Manager.

    Code:
    <script>
      fbq('track', 'Purchase', {
        value: '<?php echo $order_summary['order_total']; ?>',
        currency: 'USD',
      });
    </script>
    I have tried every variation of the "value" variable possible and none of them seem to successfully pass that order total through to Facebook.

    Does anyone know what variable I would enter in for "value" to get that order total to successfully pass through?

  2. #2
    Join Date
    Jul 2012
    Posts
    16,733
    Plugin Contributions
    17

    Default Re: Need helping finding variable for order total when used with Facebook Pixel

    Assuming that by "checkout" page you mean checkout_success, the variable is available the first time the page is loaded and only after the includes/modules/pages/checkout_success/header_php.php file has loaded.

    From the writeup it appears that the testing performed is from a live transaction and not from attempts to "see" the code. One thing to consider is whether the page pass html validation as a script is used if the page does not validate, then it is possible that the script does not/can not execute.

    If attempting to review the source code, then recommend preventing deletion of the associated session data so that upon "second" viewing that the data remains present for display.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  3. #3
    Join Date
    Feb 2007
    Location
    Ontario, Canada
    Posts
    234
    Plugin Contributions
    0

    Default Re: Need helping finding variable for order total when used with Facebook Pixel

    I can ask a silly question ..... Was this just inserted at the end of your
    includes/template/YOURTEMPLATE/checkout_success/tpl_footer.php file? Or does it need to be in some sort of php tags?

    Code:
    <script>
      fbq('track', 'Purchase', {
        value: '<?php echo $order_summary['order_total']; ?>',
        currency: 'USD',
      });
    </script>
    Thanks, Colleen
    www.af-company.com
    To err is human, but to really foul things up requires a computer. Farmers' Almanac, 1978

  4. #4
    Join Date
    Feb 2006
    Location
    Tampa Bay, Florida
    Posts
    9,695
    Plugin Contributions
    123

    Default Re: Need helping finding variable for order total when used with Facebook Pixel

    It's outside PHP - it runs in the context of the browser.
    That Software Guy. My Store: Zen Cart Modifications
    Available for hire - See my ad in Services
    Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
    Do you benefit from Zen Cart? Then please support the project.

  5. #5
    Join Date
    Nov 2005
    Location
    los angeles
    Posts
    2,691
    Plugin Contributions
    9

    Default Re: Need helping finding variable for order total when used with Facebook Pixel

    Quote Originally Posted by margecc View Post
    To err is human, but to really foul things up requires a computer. Farmers' Almanac, 1978
    actually it was shakespeare who stated:

    "to err is human, but to really f- things up, you need a computer... and to f- things up royally, you need sql..."

    with regards to the OP, if placed in the right spot, that code seems correct. however, if the pixel is not installed correctly as stated here:

    https://developers.facebook.com/docs...implementation

    calling fbq will do nothing.

    if one thinks the problems is with the php echo statement, then just put in an arbitrary number to see if that makes it to the book of faces....

    my guess is that the pixel is not installed correctly or else the call to the fbq function is done in the wrong place. i could be wrong.

    good luck.
    author of square Webpay.
    mxWorks has premium plugins. donations: venmo or paypal accepted.
    premium consistent excellent support. available for hire.

 

 

Similar Threads

  1. facebook javascript for remarketing pixel
    By juneloweelyn in forum Templates, Stylesheets, Page Layout
    Replies: 0
    Last Post: 24 Mar 2014, 02:27 AM
  2. Server Side Variable Name for Order Total?
    By MikeMurphyINC in forum Code Collaboration
    Replies: 4
    Last Post: 5 Mar 2014, 09:46 PM
  3. Salemaker total when used with Specials
    By GTHENRY in forum General Questions
    Replies: 0
    Last Post: 13 Jan 2011, 11:54 PM
  4. Replies: 1
    Last Post: 12 Jul 2009, 03:28 AM
  5. Need Order Total Variable For iDevAffiliate
    By etrader in forum General Questions
    Replies: 5
    Last Post: 19 Jun 2006, 07:57 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR