Post by fantastico » Tue Dec 13, 2016 6:14 am

Hi all,

I have my fb pixel code before the </head> tag in /catalog/view/theme/default/template/common/header.tpl so it runs on all pages.
I would like to add the purchase tracking code fbq('track', 'Purchase', {value: '0.00', currency: 'USD'}); only on checkout/checkout page just under fbq('track','PageView'); just as in the attached file.

I tried adding this to the pixel but it did not work:
if (isset($this->request->get['route']) && $this->request->get['route'] == 'checkout/checkout') {
fbq('track', 'Purchase', {value: '0.00', currency: 'USD'});
}
i got the following error in the pixel helper extension:
"The Facebook pixel code on this page didn't load, so no information was sent to Facebook"

How can i add the purchase tracking line to the checkout page only?
Appreciate your help!

Attachments

11409193_1605465096376853_497323941_n.jpg

11409193_1605465096376853_497323941_n.jpg (193.38 KiB) Viewed 2181 times


New member

Posts

Joined
Wed Feb 20, 2013 2:47 am

Post by opencartmart » Tue Dec 13, 2016 3:27 pm

fantastico wrote: I tried adding this to the pixel but it did not work:
if (isset($this->request->get['route']) && $this->request->get['route'] == 'checkout/checkout') {
fbq('track', 'Purchase', {value: '0.00', currency: 'USD'});
}
$this->request->get is not available inside template files. Use $_GET method directly instead.

Code: Select all

 <?php if (isset($_GET['route']) && $_GET['route'] == 'checkout/checkout') { ?>
fbq('track', 'Purchase', {value: '0.00', currency: 'USD'});
 <?php
 }
?>

XForm - Opencart Form Builder
Xshippingpro - An advanced Shipping Module
Need Professional support? Skype: opencartmart


Active Member

Posts

Joined
Wed Oct 02, 2013 3:59 am

Post by fantastico » Tue Dec 13, 2016 7:51 pm

Awesome!
Much appreciated, thanks.

New member

Posts

Joined
Wed Feb 20, 2013 2:47 am

Post by opencartmart » Tue Dec 13, 2016 9:34 pm

You are welcome!

XForm - Opencart Form Builder
Xshippingpro - An advanced Shipping Module
Need Professional support? Skype: opencartmart


Active Member

Posts

Joined
Wed Oct 02, 2013 3:59 am
Who is online

Users browsing this forum: No registered users and 44 guests