خرید بک لینک

Vote count: 0

I am trying to add Facebook Pixel tracking to a Magento site. Specifically I want to track the click of add to cart, the click on add to wishlist and also the success page. I am using the below code in my head.phtml file. However my Chrome browser Facebook Pixel Helper extension says "Facebook Pixel did not load". I am wondering if anyone can help identify the error in my below code.

    <!-- FACEBOOK CONVERSION TRACKING -->
    <?php if((strpos($_SERVER['REQUEST_URI'],'success')==true)):
      $orderObj = Mage::getModel('sales/order')->loadByIncrementId(Mage::getSingleton('checkout/session')->getLastRealOrderId()); 
    ?>
        <script type="text/javascript">
        var fb_param = {};
        fb_param.pixel_id = 'xxxxx';                               
        fb_param.value = '<?php echo number_format($orderObj->getBaseGrandTotal(),2) ?>';
        fb_param.currency = '<?php echo $orderObj->getOrderCurrencyCode()?>';
        (function(){
          var fpw = document.createElement('script');
          fpw.async = true;
          fpw.src = '//coect.facebook.net/en_US/fp.js';
          var ref = document.getElementsByTagName('script')[0];
          ref.parentNode.insertBefore(fpw, ref);
        })();
        </script>
        <noscript><img height="1" width="1" alt="" style="display:none" src="https://www.facebook.com/offsite_event.php?id=xxxxxx&value=<?php echo number_format($orderObj->getBaseGrandTotal(),2) ?>&currency=<?php echo $orderObj->getOrderCurrencyCode()?>" [^] /></noscript>
    <?php 
    endif; 
      if($this->getRequest()->getControllerName()=='product')
     {
         $asku = Mage::registry('current_product')->getSku();
         $pname = Mage::registry('current_product')->getName();
         $pprice = number_format(Mage::registry('current_product')->getPrice(),2);
?>
       <script type="text/javascript">
           $('.btn-cart').click(function(){fbq('init','1413656545327275');
     fbq('track','AddToCart',{content_name:'<?php echo "$pname"; ?>',content_category:'',content_ids:['<?php echo "$asku"?>'],content_type:'product',value:<?php echo "$pprice"; ?>,currency:'USD'});

      $('.link-wishlist').click(function(){fbq('init','1413656545327275');
     fbq('track','AddToCart',{content_name:'<?php echo "$pname"; ?>',content_category:'',content_ids:['<?php echo "$asku"?>'],content_type:'product',value:<?php echo "$pprice"; ?>,currency:'USD'});
});
</script>
   <?php
      }
    ?><?php 
    endif; 
      if($this->getRequest()->getControllerName()=='product')
     {
       $asku = Mage::registry('current_product')->getSku();
       $pname = Mage::registry('current_product')->getName();
       $pprice = number_format(Mage::registry('current_product')->getPrice(),2);
?>
          <script type="text/javascript">
              $('.btn-cart').click(function(){fbq('init','1413656545327275');
             fbq('track','AddToCart',{content_name:'<?php echo "$pname"; ?>',content_category:'',content_ids:['<?php echo "$asku"?>'],content_type:'product',value:<?php echo "$pprice"; ?>,currency:'USD'});

         $('.link-wishlist').click(function(){fbq('init','1413656545327275');
          fbq('track','AddToCart',{content_name:'<?php echo "$pname"; ?>',content_category:'',content_ids:['<?php echo "$asku"?>'],content_type:'product',value:<?php echo "$pprice"; ?>,currency:'USD'}); 
      });
     </script>
      <?php
          }
       ?>
asked 1 min ago

برچسب: نویسنده: استخدام کار تاريخ: چهارشنبه 25 فروردين 1395 ساعت: 5:17

صفحه بندی