Skip to main content

Facebook Tracking Code

More
12 years 3 months ago - 12 years 3 months ago #162183 by rafael_josem
-- 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:
Code:
<!-- 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: 12 years 3 months ago by rafael_josem.

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

More
12 years 3 months ago #162188 by nicolas
Replied by nicolas on topic Facebook Tracking Code
Hi,

You want to add such code in the "end" file of the view "checkout" via the menu Display>Views:
Code:
$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.

More
12 years 3 months ago #162259 by rafael_josem
Replied by rafael_josem on topic Facebook Tracking Code
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.167 seconds
Powered by Kunena Forum