Facebook Tracking Code

  • Posts: 4
  • Thank you received: 0
10 years 11 months ago #162183

-- url of the page with the problem -- : epensare.com/
-- HikaShop version -- : 2.3.1
-- Joomla version -- : 3.3.1
-- PHP version -- : 5.4.28
-- Browser(s) name and version -- : Chrome 35.0
-- Error-message(debug-mod must be tuned on) -- :N/A


Hello

I would like to know how to add this facebook tracking code at the end of check out:

<!-- Facebook Conversion Code for Compras Pensare -->
<script>(function() {
  var _fbq = window._fbq || (window._fbq = []);
  if (!_fbq.loaded) {
    var fbds = document.createElement('script');
    fbds.async = true;
    fbds.src = '//connect.facebook.net/en_US/fbds.js';
    var s = document.getElementsByTagName('script')[0];
    s.parentNode.insertBefore(fbds, s);
    _fbq.loaded = true;
  }
})();
window._fbq = window._fbq || [];
window._fbq.push(['track', '123456789', {'value':'0.00','currency':'USD'}]);
</script>
<noscript><img height="1" width="1" alt="" style="display:none" src="https://www.facebook.com/tr?ev=123456789&amp;cd[value]=0.00&amp;cd[currency]=USD&amp;noscript=1" /></noscript>

In the line: window._fbq.push(); the "value" must be the price of the item that was purchased by the user. Also, this code must be placed between the head tags of the site.

I'm using bank transfer and Paypal as payment methods.

Thanks,

RJ

Last edit: 10 years 11 months ago by rafael_josem.

Please Log in or Create an account to join the conversation.

  • Posts: 83993
  • Thank you received: 13605
  • MODERATOR
10 years 11 months ago #162188

Hi,

You want to add such code in the "end" file of the view "checkout" via the menu Display>Views:

$app = JFactory::getApplication();
$order_id = $app->getUserState('com_hikashop.order_id');
$orderClass = hikashop_get('class.order');
$order = $orderClass->loadFullOrder($order_id,false,false);
$js ="(function() {
  var _fbq = window._fbq || (window._fbq = []);
  if (!_fbq.loaded) {
    var fbds = document.createElement('script');
    fbds.async = true;
    fbds.src = '//connect.facebook.net/en_US/fbds.js';
    var s = document.getElementsByTagName('script')[0];
    s.parentNode.insertBefore(fbds, s);
    _fbq.loaded = true;
  }
})();
window._fbq = window._fbq || [];
window._fbq.push(['track', '123456789', {'value':'".round($order->order_full_price,2)."','currency':'USD'}]);";
$doc = JFactory::getDocument();
$doc->addScriptDeclaration($js);

Please Log in or Create an account to join the conversation.

  • Posts: 4
  • Thank you received: 0
10 years 11 months ago #162259

Hello,

it didnt work in the "end" file but it did work in the "after end"

Thanks.

Please Log in or Create an account to join the conversation.

Time to create page: 0.040 seconds
Powered by Kunena Forum