Results 1 to 8 of 8
  1. #1
    Join Date
    May 2005
    Posts
    535
    Plugin Contributions
    0

    Default Facebook Advertising Pixel tracking code.

    Has anyone used the facebook tracking code on zencart Facebook call it pixels. I can see how to get the script code into the header and have pasted this in the file common/html_header.php

    I am unsure about part 2 to the process which is to past the tracking event code on to the specific pages that you wish to track. eg add to cart or conversions. and example that they give would be to use the code fbq('track', 'AddToCart'); to track any adding to the cart that takes place a s a result of the advert.

    I am not sure though i this is all I need enter on the cart page or if I need more script (i.e. the original part of the pixel script that they give you but change the view page part for the add to cart part.

    Has anyone implemented this at all and are they able to enlighten to the exact position and code used for tracking specific events?

    Thank you.

    Regards

    MikeyG

  2. #2
    Join Date
    May 2016
    Location
    Bucharest
    Posts
    48
    Plugin Contributions
    0

    Default Re: Facebook Advertising Pixel tracking code.

    Hi, I've been looking for this answer for a long time, I managed to install the Purchase event. Here's How i did:

    I installed The Base pixel in the html_header.php to track like you did and after that i made o copy of it and pasted in /includes/templates/custom_template/checkout_success (I've created an override folder named checkout_success)

    The only line I changed was fbq('track', 'PageView'); with fbq('track', 'Purchase', {value: '0.00', currency:'RON'});

    It seems to work for me the Purchase Pixel appeared in my FB Ad Account, i made a test order and the conversion showed up.

    Hope it helps, I've searched the whole Internet for a solution.

    <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', 'your_ID', {
    em: 'insert_email_variable'
    });
    fbq('track', 'Purchase', {value: '0.00', currency:'RON'});
    </script>
    <noscript><img height="1" width="1" style="display:none"
    src="https://www.facebook.com/tr?id=1161150290679753&ev=PageView&noscript=1"
    /></noscript>
    <!-- DO NOT MODIFY -->
    <!-- End Facebook Pixel Code -->

  3. #3
    Join Date
    May 2008
    Posts
    182
    Plugin Contributions
    0

    Default Re: Facebook Advertising Pixel tracking code.

    I have added mine in via Google Tag Manager. (Saves having to mess around with potentially breaking something)
    May be easier in the long run as you can also add/change on the fly.
    Download the Chrome Extension for Facebook Pixel as well as it does help
    www.candlewithcare.co.uk
    Luxury Scented
    Candles at great prices!

  4. #4
    Join Date
    Jan 2007
    Posts
    1,483
    Plugin Contributions
    10

    Default Re: Facebook Advertising Pixel tracking code.

    I believe there is more to it than that if you want to track sales and campaign conversions and sales totals. You need to give it values from the orders, which is pulled from the checkout success page for transaction totals. There are some FAQ pages here regarding tracking pixels that show what variables map to what values you are seeking.

    Zen Cart and it's community are the best!!

  5. #5
    Join Date
    Sep 2017
    Posts
    1
    Plugin Contributions
    0

    Default Re: Facebook Advertising Pixel tracking code.

    I am also using the Facebook Ads Services from Visiblefactors.com and this team is doing great work for my business growth. I get huge visitors from FB ads and most of them convert into my customers. I am so pleased with their work.

  6. #6
    Join Date
    Mar 2005
    Location
    Earth
    Posts
    92
    Plugin Contributions
    0

    Default Re: Facebook Advertising Pixel tracking code.

    Can anyone help me integrate the latest 2024 FaceBook Meta Pixel Dataset with Zen Cart 1.5.8?
    I'm paying for FB advertising and I've got my access token for the Conversions API

  7. #7
    Join Date
    Mar 2006
    Location
    Auckland, New Zealand
    Posts
    243
    Plugin Contributions
    0

    Default Re: Facebook Advertising Pixel tracking code.

    I'd like to know this too. I just tried to set up an event on FB and it won't let me because I don't have the latest whatever it is meant to be...

    This is the error message I get
    "Update the Facebook SDK for iOS
    Your app is out of date. To run your app on iOS 14, update to the latest Facebook SDK for iOS."

    Is that what you are getting too Charmlt?
    Elemi

    The Art of Bespoke Aromatherapy
    www.AmorAromatherapy.co.nz

  8. #8
    Join Date
    Jan 2015
    Posts
    501
    Plugin Contributions
    0

    Default Re: Facebook Advertising Pixel tracking code.

    zencart 1.5.8
    php 8.1

    Place code in /includes/templates/bootstrap/common/tpl_main_page.php
    This is the script that will make the Facebook pixel work correctly.
    a. Please note that I have one page checkoutout plugin implemented to use in the script.
    b. remember to add your pixel id to where is says you see xxxxxxxx (two place to change)
    c. Use facebook tags assisant to verify your values are correct


    Code:
    <!--  Facebook Dynamic Remarketing 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', 'xxxxxxxx');  // Insert your pixel ID here.
      fbq('track', 'PageView');
      
      <?php
    switch($_GET['main_page']) {
        case 'shopping_cart': // Changed from FILENAME_SHOPPING_CART to 'shopping_cart'
        case 'ajax_shopping_cart': // Changed from 'FILENAME_AJAX_SHOPPING_CART' to 'ajax_shopping_cart'
            $products = $_SESSION['cart']->get_products();
            $product_ids = array();
            foreach ($products as $product) {
                $product_ids[] = (int)$product['id'];
            }
            echo "fbq('track', 'AddToCart', {
                content_ids: ['" . implode("','", $product_ids) . "'],
                content_type: 'product',
                value: " . number_format($_SESSION['cart']->show_total(), 2, '.', '') . ",
                currency: '" . $_SESSION['currency'] . "'
            });\n";
            break;
        case 'checkout_shipping': // Changed from FILENAME_CHECKOUT_SHIPPING to 'checkout_shipping'
        case 'checkout_payment': // Changed from FILENAME_CHECKOUT to 'checkout_payment'
        case 'quick_checkout': // Changed from 'FILENAME_QUICK_CHECKOUT' to 'quick_checkout'
        case 'checkout_one': // Changed from 'FILENAME_ONE_PAGE_CHECKOUT' to 'one_page_checkout'
            $products = $_SESSION['cart']->get_products();
            $product_ids = array();
            foreach ($products as $product) {
                $product_ids[] = (int)$product['id'];
            }
            echo "fbq('track', 'InitiateCheckout', {
                content_ids: ['" . implode("','", $product_ids) . "'],
                num_items: " . (int)$_SESSION['cart']->count_contents() . ",
                content_type: 'product',
                value: " . number_format($_SESSION['cart']->show_total(), 2, '.', '') . ",
                currency: '" . $_SESSION['currency'] . "'
            });\n";
            break;
        case 'checkout_success': // Changed from FILENAME_CHECKOUT_SUCCESS to 'checkout_success'
            if ($zv_orders_id > 0) {
                if(!class_exists('order')) require_once DIR_WS_CLASSES . 'order.php';
                $order = new order($zv_orders_id);
                $products = $order->products;
                $fbp_pids = array();
                foreach ($products as $product) {
                    $fbp_pids[] = (int)$product['id'];
                }
                echo "fbq('track', 'Purchase', {
                    value: " . number_format($order->info['total'], 2, '.', '') . ",
                    currency: '" . $_SESSION['currency'] . "',
                    content_type: 'product',
                    content_ids: ['" . implode("','", $fbp_pids) . "']
                });";
            }
            break;
        case 'search_result': // Adding search tracking
            if (isset($_GET['keyword']) && !empty($_GET['keyword'])) {
                echo "fbq('track', 'Search', {
                    search_string: '" . addslashes($_GET['keyword']) . "'
                });\n";
            }
            break;
        default:
            if (isset($_GET['products_id'])) {
                echo "fbq('track', 'ViewContent', {
                    value: " . number_format(zen_get_products_special_price($_GET['products_id']), 2, '.', '') . ",
                    currency: '" . $_SESSION['currency'] . "',
                    content_type: 'product',
                    content_ids: ['" . (int)$_GET['products_id'] . "']
                });\n";
            }
            break;
    }
    ?>
    </script>
    <noscript><img height="1" width="1" style="display:none"
      src="https://www.facebook.com/tr?id=xxxxxxxxx&ev=PageView&noscript=1" 
    /></noscript>
    <!-- End Facebook Pixel Code -->
    Last edited by chadlly2003; 14 Aug 2024 at 04:59 PM.

 

 

Similar Threads

  1. v139h i wanna install facebook pixel into my website
    By juneloweelyn in forum Basic Configuration
    Replies: 4
    Last Post: 10 Apr 2016, 11:21 AM
  2. v138a Facebook and Twitter tracking code placement
    By 007mcfod in forum General Questions
    Replies: 1
    Last Post: 24 Aug 2014, 01:48 AM
  3. facebook javascript for remarketing pixel
    By juneloweelyn in forum Templates, Stylesheets, Page Layout
    Replies: 0
    Last Post: 24 Mar 2014, 02:27 AM
  4. v151 Affiliate Pixel Tracking - Commision Junction Tracking
    By penamas in forum General Questions
    Replies: 4
    Last Post: 11 Sep 2013, 04:01 PM

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