[Skip to main content](#vessel-content)

#   Facebook Pixel Firing Twice for Paypal

##

- **[mojooutdoors-holden](/forum/user/12526-mojooutdoors-holden "View mojooutdoors-holden's Profile")**
- [![mojooutdoors-holden's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/12526-mojooutdoors-holden "View mojooutdoors-holden's Profile") Topic Author
- [ Offline](/forum/user/12526-mojooutdoors-holden)

Less More

- Posts: 303
- Thank you received: 18
-
-

8 years 8 months ago [\#290368](#290368) by [mojooutdoors-holden](/forum/user/12526-mojooutdoors-holden "View mojooutdoors-holden's Profile")  *[Facebook Pixel Firing Twice for Paypal](/forum/27-checkout/894259-facebook-pixel-firing-twice-for-paypal#290368 "-- HikaShop version -- : 3.2.2 -- Joomla version -- : 3.8.5  I've added my Facebook Tracking pixel to the top of the &quot;after&#95;end&quot; view. As you get redirected to Paypal, everything is fine. Normally, you would expect the pixel to fire once payment has been confirmed in paypal and after the redirection back to the thank you page (after&#95;end view file). However, if you cancel the paypal payment and return to the payment window on my site, the pixel fires....even though the &quot;after&#95;end&quot; file has not been called.  I've checked multiple times and the pixel is only on the &quot;end&quot; (for first data payment) and &quot;after&#95;end&quot; (for PayPal). Any reason why canceling the PayPal payment would result in the &quot;after&#95;end&quot; view file being called? Then, in the case where users canceled it and decided to pay with First Data, i see an instance where the pixel was fired twice for the same purchase. Obviously, this is showing false positives in my tracking statistics.  I should note that it's working properly for all confirmed orders, and seems to only be a problem on orders where customers cancel the payment and return to our website. The only reason I noticed this behavior is the Facebook conversion stats show I sold more than what I actually sold. The difference seems to be the canceled payment amount.")* was created by *[mojooutdoors-holden](/forum/user/12526-mojooutdoors-holden "View mojooutdoors-holden's Profile")*

-- HikaShop version -- : 3.2.2
-- Joomla version -- : 3.8.5

I've added my Facebook Tracking pixel to the top of the "after_end" view. As you get redirected to Paypal, everything is fine. Normally, you would expect the pixel to fire once payment has been confirmed in paypal and after the redirection back to the thank you page (after_end view file). However, if you cancel the paypal payment and return to the payment window on my site, the pixel fires....even though the "after_end" file has not been called.

I've checked multiple times and the pixel is only on the "end" (for first data payment) and "after_end" (for PayPal). Any reason why canceling the PayPal payment would result in the "after_end" view file being called? Then, in the case where users canceled it and decided to pay with First Data, i see an instance where the pixel was fired twice for the same purchase. Obviously, this is showing false positives in my tracking statistics.

I should note that it's working properly for all confirmed orders, and seems to only be a problem on orders where customers cancel the payment and return to our website. The only reason I noticed this behavior is the Facebook conversion stats show I sold more than what I actually sold. The difference seems to be the canceled payment amount.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI3LWNoZWNrb3V0Lzg5NDI1OS1mYWNlYm9vay1waXhlbC1maXJpbmctdHdpY2UtZm9yLXBheXBhbD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86587
- Thank you received: 14326
-
-

8 years 8 months ago [\#290377](#290377) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Facebook Pixel Firing Twice for Paypal](/forum/27-checkout/894259-facebook-pixel-firing-twice-for-paypal#290377 "-- HikaShop version -- : 3.2.2 -- Joomla version -- : 3.8.5  I've added my Facebook Tracking pixel to the top of the &quot;after&#95;end&quot; view. As you get redirected to Paypal, everything is fine. Normally, you would expect the pixel to fire once payment has been confirmed in paypal and after the redirection back to the thank you page (after&#95;end view file). However, if you cancel the paypal payment and return to the payment window on my site, the pixel fires....even though the &quot;after&#95;end&quot; file has not been called.  I've checked multiple times and the pixel is only on the &quot;end&quot; (for first data payment) and &quot;after&#95;end&quot; (for PayPal). Any reason why canceling the PayPal payment would result in the &quot;after&#95;end&quot; view file being called? Then, in the case where users canceled it and decided to pay with First Data, i see an instance where the pixel was fired twice for the same purchase. Obviously, this is showing false positives in my tracking statistics.  I should note that it's working properly for all confirmed orders, and seems to only be a problem on orders where customers cancel the payment and return to our website. The only reason I noticed this behavior is the Facebook conversion stats show I sold more than what I actually sold. The difference seems to be the canceled payment amount.")*

Hi,

The after_end view file is only called after the paypal payment. It cannot be called before. I don't see how it would.
I presume that it must be the pixel code you've added in the "end" view file which is fired when it shouldn't because of the way you added it to it.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI3LWNoZWNrb3V0Lzg5NDI1OS1mYWNlYm9vay1waXhlbC1maXJpbmctdHdpY2UtZm9yLXBheXBhbD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[mojooutdoors-holden](/forum/user/12526-mojooutdoors-holden "View mojooutdoors-holden's Profile")**
- [![mojooutdoors-holden's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/12526-mojooutdoors-holden "View mojooutdoors-holden's Profile") Topic Author
- [ Offline](/forum/user/12526-mojooutdoors-holden)

Less More

- Posts: 303
- Thank you received: 18
-
-

8 years 8 months ago [\#290437](#290437) by [mojooutdoors-holden](/forum/user/12526-mojooutdoors-holden "View mojooutdoors-holden's Profile")  Replied by *[mojooutdoors-holden](/forum/user/12526-mojooutdoors-holden "View mojooutdoors-holden's Profile")* on topic *[Facebook Pixel Firing Twice for Paypal](/forum/27-checkout/894259-facebook-pixel-firing-twice-for-paypal#290437 "-- HikaShop version -- : 3.2.2 -- Joomla version -- : 3.8.5  I've added my Facebook Tracking pixel to the top of the &quot;after&#95;end&quot; view. As you get redirected to Paypal, everything is fine. Normally, you would expect the pixel to fire once payment has been confirmed in paypal and after the redirection back to the thank you page (after&#95;end view file). However, if you cancel the paypal payment and return to the payment window on my site, the pixel fires....even though the &quot;after&#95;end&quot; file has not been called.  I've checked multiple times and the pixel is only on the &quot;end&quot; (for first data payment) and &quot;after&#95;end&quot; (for PayPal). Any reason why canceling the PayPal payment would result in the &quot;after&#95;end&quot; view file being called? Then, in the case where users canceled it and decided to pay with First Data, i see an instance where the pixel was fired twice for the same purchase. Obviously, this is showing false positives in my tracking statistics.  I should note that it's working properly for all confirmed orders, and seems to only be a problem on orders where customers cancel the payment and return to our website. The only reason I noticed this behavior is the Facebook conversion stats show I sold more than what I actually sold. The difference seems to be the canceled payment amount.")*

I added the script to the beginning of the end file before the opening &lt;?php. Could this be the problem? Or more likely, is this due to me using an older version of the "end" and "after_end" display views?
Code:

&lt;!-- Facebook Event snippet conversion page --&gt; &lt;script&gt; fbq('track', 'Purchase', &lt;?php if(!defined('DS')) define('DS', DIRECTORY_SEPARATOR); if(!include_once(rtrim(JPATH_ADMINISTRATOR,DS).DS.'components'.DS.'com_hikashop'.DS.'helpers'.DS.'helper.php')) return true; $app =JFactory::getApplication(); $order_id = $app-&gt;getUserState('com_hikashop.order_id'); $orderClass = hikashop_get('class.order'); $order = $orderClass-&gt;get($order_id); $currencyClass = hikashop_get('class.currency'); $currency_id = intval($order-&gt;order_currency_id); $currency = $currencyClass-&gt;getCurrencies($currency_id, $null); echo "{value: ".$order-&gt;order_full_price.", currency:'".$currency[$currency_id]-&gt;currency_code."'}"; ?&gt;); &lt;/script&gt; &lt;?php /** * @package HikaShop for Joomla! * @version 2.6.1 * @author hikashop.com * @copyright (C) 2010-2016 HIKARI SOFTWARE. All rights reserved. * @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html */ defined('_JEXEC') or die('Restricted access'); ?&gt; &lt;?php if(empty($this-&gt;html)){ echo '&lt;div class="span6"&gt;'; echo JText::_('THANK_YOU_FOR_PURCHASE'); echo '&lt;/div&gt;'; }else{ echo '&lt;div class="span6"&gt;'; echo $this-&gt;html; echo '&lt;/div&gt;'; } $this-&gt;nextButton = false;

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI3LWNoZWNrb3V0Lzg5NDI1OS1mYWNlYm9vay1waXhlbC1maXJpbmctdHdpY2UtZm9yLXBheXBhbD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[mojooutdoors-holden](/forum/user/12526-mojooutdoors-holden "View mojooutdoors-holden's Profile")**
- [![mojooutdoors-holden's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/12526-mojooutdoors-holden "View mojooutdoors-holden's Profile") Topic Author
- [ Offline](/forum/user/12526-mojooutdoors-holden)

Less More

- Posts: 303
- Thank you received: 18
-
-

8 years 8 months ago -  8 years 8 months ago [\#290445](#290445) by [mojooutdoors-holden](/forum/user/12526-mojooutdoors-holden "View mojooutdoors-holden's Profile")  Replied by *[mojooutdoors-holden](/forum/user/12526-mojooutdoors-holden "View mojooutdoors-holden's Profile")* on topic *[Facebook Pixel Firing Twice for Paypal](/forum/27-checkout/894259-facebook-pixel-firing-twice-for-paypal#290445 "-- HikaShop version -- : 3.2.2 -- Joomla version -- : 3.8.5  I've added my Facebook Tracking pixel to the top of the &quot;after&#95;end&quot; view. As you get redirected to Paypal, everything is fine. Normally, you would expect the pixel to fire once payment has been confirmed in paypal and after the redirection back to the thank you page (after&#95;end view file). However, if you cancel the paypal payment and return to the payment window on my site, the pixel fires....even though the &quot;after&#95;end&quot; file has not been called.  I've checked multiple times and the pixel is only on the &quot;end&quot; (for first data payment) and &quot;after&#95;end&quot; (for PayPal). Any reason why canceling the PayPal payment would result in the &quot;after&#95;end&quot; view file being called? Then, in the case where users canceled it and decided to pay with First Data, i see an instance where the pixel was fired twice for the same purchase. Obviously, this is showing false positives in my tracking statistics.  I should note that it's working properly for all confirmed orders, and seems to only be a problem on orders where customers cancel the payment and return to our website. The only reason I noticed this behavior is the Facebook conversion stats show I sold more than what I actually sold. The difference seems to be the canceled payment amount.")*

Fixed the pixel firing by moving the script withing &lt;?php if(empty($this-&gt;html)){ XXXX } ?&gt;

The only other question i have is how to prevent the pixel from firing again if you reload the thank you page???

Last edit: 8 years 8 months ago by [mojooutdoors-holden](/forum/user/12526-mojooutdoors-holden "View mojooutdoors-holden's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI3LWNoZWNrb3V0Lzg5NDI1OS1mYWNlYm9vay1waXhlbC1maXJpbmctdHdpY2UtZm9yLXBheXBhbD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86587
- Thank you received: 14326
-
-

8 years 8 months ago [\#290472](#290472) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Facebook Pixel Firing Twice for Paypal](/forum/27-checkout/894259-facebook-pixel-firing-twice-for-paypal#290472 "-- HikaShop version -- : 3.2.2 -- Joomla version -- : 3.8.5  I've added my Facebook Tracking pixel to the top of the &quot;after&#95;end&quot; view. As you get redirected to Paypal, everything is fine. Normally, you would expect the pixel to fire once payment has been confirmed in paypal and after the redirection back to the thank you page (after&#95;end view file). However, if you cancel the paypal payment and return to the payment window on my site, the pixel fires....even though the &quot;after&#95;end&quot; file has not been called.  I've checked multiple times and the pixel is only on the &quot;end&quot; (for first data payment) and &quot;after&#95;end&quot; (for PayPal). Any reason why canceling the PayPal payment would result in the &quot;after&#95;end&quot; view file being called? Then, in the case where users canceled it and decided to pay with First Data, i see an instance where the pixel was fired twice for the same purchase. Obviously, this is showing false positives in my tracking statistics.  I should note that it's working properly for all confirmed orders, and seems to only be a problem on orders where customers cancel the payment and return to our website. The only reason I noticed this behavior is the Facebook conversion stats show I sold more than what I actually sold. The difference seems to be the canceled payment amount.")*

Hi,

Indeed, the way you had the code placed there meant that the pixel was also added for each paypal transaction since the paypal payment method also uses the "end" view before the redirection to add its form to it through the $this-&gt;html variable.
Placing it in the if is indeed a good solution.
To avoid your code running several times if the customer reload the page, you should set a variable in the user session and check against it.
Something like that: Code:

if(!isset($_SESSION['pixel_displayed'])) { $_SESSION['pixel_displayed'] = true; // your code }

Note also that since the view files of HikaShop are in HikaShop, HikaShop is already loaded.
So the code Code:

if(!defined('DS')) define('DS', DIRECTORY_SEPARATOR); if(!include_once(rtrim(JPATH_ADMINISTRATOR,DS).DS.'components'.DS.'com_hikashop'.DS.'helpers'.DS.'helper.php')) return true;

is not necessary in the view files of HikaShop or in the plugins of the group "hikashop", "hikashoppayment" or "hikashopshipping".

Note also that the code: Code:

$app =JFactory::getApplication(); $order_id = $app-&gt;getUserState('com_hikashop.order_id'); $orderClass = hikashop_get('class.order'); $order = $orderClass-&gt;get($order_id);

should also not be necessary as the order data is already available in $this-&gt;order in the "end" and the "after_end" view files.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI3LWNoZWNrb3V0Lzg5NDI1OS1mYWNlYm9vay1waXhlbC1maXJpbmctdHdpY2UtZm9yLXBheXBhbD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[mojooutdoors-holden](/forum/user/12526-mojooutdoors-holden "View mojooutdoors-holden's Profile")**
- [![mojooutdoors-holden's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/12526-mojooutdoors-holden "View mojooutdoors-holden's Profile") Topic Author
- [ Offline](/forum/user/12526-mojooutdoors-holden)

Less More

- Posts: 303
- Thank you received: 18
-
-

8 years 8 months ago [\#290506](#290506) by [mojooutdoors-holden](/forum/user/12526-mojooutdoors-holden "View mojooutdoors-holden's Profile")  Replied by *[mojooutdoors-holden](/forum/user/12526-mojooutdoors-holden "View mojooutdoors-holden's Profile")* on topic *[Facebook Pixel Firing Twice for Paypal](/forum/27-checkout/894259-facebook-pixel-firing-twice-for-paypal#290506 "-- HikaShop version -- : 3.2.2 -- Joomla version -- : 3.8.5  I've added my Facebook Tracking pixel to the top of the &quot;after&#95;end&quot; view. As you get redirected to Paypal, everything is fine. Normally, you would expect the pixel to fire once payment has been confirmed in paypal and after the redirection back to the thank you page (after&#95;end view file). However, if you cancel the paypal payment and return to the payment window on my site, the pixel fires....even though the &quot;after&#95;end&quot; file has not been called.  I've checked multiple times and the pixel is only on the &quot;end&quot; (for first data payment) and &quot;after&#95;end&quot; (for PayPal). Any reason why canceling the PayPal payment would result in the &quot;after&#95;end&quot; view file being called? Then, in the case where users canceled it and decided to pay with First Data, i see an instance where the pixel was fired twice for the same purchase. Obviously, this is showing false positives in my tracking statistics.  I should note that it's working properly for all confirmed orders, and seems to only be a problem on orders where customers cancel the payment and return to our website. The only reason I noticed this behavior is the Facebook conversion stats show I sold more than what I actually sold. The difference seems to be the canceled payment amount.")*

That worked perfectly! No issues whatsoever now. The session handler really helped out as well!

Awesome support as always!

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI3LWNoZWNrb3V0Lzg5NDI1OS1mYWNlYm9vay1waXhlbC1maXJpbmctdHdpY2UtZm9yLXBheXBhbD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[mojooutdoors-holden](/forum/user/12526-mojooutdoors-holden "View mojooutdoors-holden's Profile")**
- [![mojooutdoors-holden's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/12526-mojooutdoors-holden "View mojooutdoors-holden's Profile") Topic Author
- [ Offline](/forum/user/12526-mojooutdoors-holden)

Less More

- Posts: 303
- Thank you received: 18
-
-

8 years 8 months ago [\#290507](#290507) by [mojooutdoors-holden](/forum/user/12526-mojooutdoors-holden "View mojooutdoors-holden's Profile")  Replied by *[mojooutdoors-holden](/forum/user/12526-mojooutdoors-holden "View mojooutdoors-holden's Profile")* on topic *[Facebook Pixel Firing Twice for Paypal](/forum/27-checkout/894259-facebook-pixel-firing-twice-for-paypal#290507 "-- HikaShop version -- : 3.2.2 -- Joomla version -- : 3.8.5  I've added my Facebook Tracking pixel to the top of the &quot;after&#95;end&quot; view. As you get redirected to Paypal, everything is fine. Normally, you would expect the pixel to fire once payment has been confirmed in paypal and after the redirection back to the thank you page (after&#95;end view file). However, if you cancel the paypal payment and return to the payment window on my site, the pixel fires....even though the &quot;after&#95;end&quot; file has not been called.  I've checked multiple times and the pixel is only on the &quot;end&quot; (for first data payment) and &quot;after&#95;end&quot; (for PayPal). Any reason why canceling the PayPal payment would result in the &quot;after&#95;end&quot; view file being called? Then, in the case where users canceled it and decided to pay with First Data, i see an instance where the pixel was fired twice for the same purchase. Obviously, this is showing false positives in my tracking statistics.  I should note that it's working properly for all confirmed orders, and seems to only be a problem on orders where customers cancel the payment and return to our website. The only reason I noticed this behavior is the Facebook conversion stats show I sold more than what I actually sold. The difference seems to be the canceled payment amount.")*

One last question pertaining to the session handler. Is there any way to set the session to expire after, let's say, 5 minutes? I've never used this before, and after a quick Google search, it seemed like there were ways but it either depending on your php.ini file or there was a way to declare it inside the if statement to check the amount of time that had passed before the session variable was initialized. However, most claimed the latter didn't always work.

The reason I ask is that I tried two test orders 10 minutes apart and the second one didn't fire the pixel.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI3LWNoZWNrb3V0Lzg5NDI1OS1mYWNlYm9vay1waXhlbC1maXJpbmctdHdpY2UtZm9yLXBheXBhbD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86587
- Thank you received: 14326
-
-

8 years 8 months ago [\#290512](#290512) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Facebook Pixel Firing Twice for Paypal](/forum/27-checkout/894259-facebook-pixel-firing-twice-for-paypal#290512 "-- HikaShop version -- : 3.2.2 -- Joomla version -- : 3.8.5  I've added my Facebook Tracking pixel to the top of the &quot;after&#95;end&quot; view. As you get redirected to Paypal, everything is fine. Normally, you would expect the pixel to fire once payment has been confirmed in paypal and after the redirection back to the thank you page (after&#95;end view file). However, if you cancel the paypal payment and return to the payment window on my site, the pixel fires....even though the &quot;after&#95;end&quot; file has not been called.  I've checked multiple times and the pixel is only on the &quot;end&quot; (for first data payment) and &quot;after&#95;end&quot; (for PayPal). Any reason why canceling the PayPal payment would result in the &quot;after&#95;end&quot; view file being called? Then, in the case where users canceled it and decided to pay with First Data, i see an instance where the pixel was fired twice for the same purchase. Obviously, this is showing false positives in my tracking statistics.  I should note that it's working properly for all confirmed orders, and seems to only be a problem on orders where customers cancel the payment and return to our website. The only reason I noticed this behavior is the Facebook conversion stats show I sold more than what I actually sold. The difference seems to be the canceled payment amount.")*

Hi,

Sure. You can do like that for example: Code:

if(!isset($_SESSION['last_order_time'])) { // init of the timer $_SESSION['last_order_time'] = time(); }else{ $time_since_last_order = time() - $_SESSION['last_order_time']; if( $time_since_last_order &gt; 600) { // more than 10 minutes }else{ // less than 10 minutes } }

As you can see it's just basic PHP.

Note that in Joomla, you don't need, and shouldn't create or destroy the PHP session. That's handled by Joomla automatically for you. You just want to set a timer in it to know how much time has passed since last order.

The following user(s) said Thank You: [mojooutdoors-holden](/forum/user/12526-mojooutdoors-holden "View mojooutdoors-holden's Profile")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI3LWNoZWNrb3V0Lzg5NDI1OS1mYWNlYm9vay1waXhlbC1maXJpbmctdHdpY2UtZm9yLXBheXBhbD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[mojooutdoors-holden](/forum/user/12526-mojooutdoors-holden "View mojooutdoors-holden's Profile")**
- [![mojooutdoors-holden's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/12526-mojooutdoors-holden "View mojooutdoors-holden's Profile") Topic Author
- [ Offline](/forum/user/12526-mojooutdoors-holden)

Less More

- Posts: 303
- Thank you received: 18
-
-

8 years 7 months ago [\#290982](#290982) by [mojooutdoors-holden](/forum/user/12526-mojooutdoors-holden "View mojooutdoors-holden's Profile")  Replied by *[mojooutdoors-holden](/forum/user/12526-mojooutdoors-holden "View mojooutdoors-holden's Profile")* on topic *[Facebook Pixel Firing Twice for Paypal](/forum/27-checkout/894259-facebook-pixel-firing-twice-for-paypal#290982 "-- HikaShop version -- : 3.2.2 -- Joomla version -- : 3.8.5  I've added my Facebook Tracking pixel to the top of the &quot;after&#95;end&quot; view. As you get redirected to Paypal, everything is fine. Normally, you would expect the pixel to fire once payment has been confirmed in paypal and after the redirection back to the thank you page (after&#95;end view file). However, if you cancel the paypal payment and return to the payment window on my site, the pixel fires....even though the &quot;after&#95;end&quot; file has not been called.  I've checked multiple times and the pixel is only on the &quot;end&quot; (for first data payment) and &quot;after&#95;end&quot; (for PayPal). Any reason why canceling the PayPal payment would result in the &quot;after&#95;end&quot; view file being called? Then, in the case where users canceled it and decided to pay with First Data, i see an instance where the pixel was fired twice for the same purchase. Obviously, this is showing false positives in my tracking statistics.  I should note that it's working properly for all confirmed orders, and seems to only be a problem on orders where customers cancel the payment and return to our website. The only reason I noticed this behavior is the Facebook conversion stats show I sold more than what I actually sold. The difference seems to be the canceled payment amount.")*

Works perfectly! Thanks again for the awesome support!

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI3LWNoZWNrb3V0Lzg5NDI1OS1mYWNlYm9vay1waXhlbC1maXJpbmctdHdpY2UtZm9yLXBheXBhbD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[mojooutdoors-holden](/forum/user/12526-mojooutdoors-holden "View mojooutdoors-holden's Profile")**
- [![mojooutdoors-holden's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/12526-mojooutdoors-holden "View mojooutdoors-holden's Profile") Topic Author
- [ Offline](/forum/user/12526-mojooutdoors-holden)

Less More

- Posts: 303
- Thank you received: 18
-
-

8 years 7 months ago [\#291332](#291332) by [mojooutdoors-holden](/forum/user/12526-mojooutdoors-holden "View mojooutdoors-holden's Profile")  Replied by *[mojooutdoors-holden](/forum/user/12526-mojooutdoors-holden "View mojooutdoors-holden's Profile")* on topic *[Facebook Pixel Firing Twice for Paypal](/forum/27-checkout/894259-facebook-pixel-firing-twice-for-paypal#291332 "-- HikaShop version -- : 3.2.2 -- Joomla version -- : 3.8.5  I've added my Facebook Tracking pixel to the top of the &quot;after&#95;end&quot; view. As you get redirected to Paypal, everything is fine. Normally, you would expect the pixel to fire once payment has been confirmed in paypal and after the redirection back to the thank you page (after&#95;end view file). However, if you cancel the paypal payment and return to the payment window on my site, the pixel fires....even though the &quot;after&#95;end&quot; file has not been called.  I've checked multiple times and the pixel is only on the &quot;end&quot; (for first data payment) and &quot;after&#95;end&quot; (for PayPal). Any reason why canceling the PayPal payment would result in the &quot;after&#95;end&quot; view file being called? Then, in the case where users canceled it and decided to pay with First Data, i see an instance where the pixel was fired twice for the same purchase. Obviously, this is showing false positives in my tracking statistics.  I should note that it's working properly for all confirmed orders, and seems to only be a problem on orders where customers cancel the payment and return to our website. The only reason I noticed this behavior is the Facebook conversion stats show I sold more than what I actually sold. The difference seems to be the canceled payment amount.")*

I have one more issue. Now that the pixel is firing for the Paypal orders, it's not firing for the credit card orders.

I believe the view file that displays after the credit card payment is processed is "checkout/end.php"

Currently I have the following:

Code:

&lt;?php /** * @package HikaShop for Joomla! * @version 3.2.2 * @author hikashop.com * @copyright (C) 2010-2018 HIKARI SOFTWARE. All rights reserved. * @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html */ defined('_JEXEC') or die('Restricted access'); ?&gt;&lt;?php if(empty($this-&gt;html)) { echo JText::_('THANK_YOU_FOR_PURCHASE'); $user = JFactory::getUser(); if(!$user-&gt;guest) { $url = hikashop_completeLink('order&amp;task=show&amp;cid='.$this-&gt;order-&gt;order_id); ?&gt; &lt;!-- Facebook Event snippet for Turkey Sales conversion page --&gt; &lt;script&gt; fbq('track', 'Purchase', &lt;?php echo "{value: ".$this-&gt;order-&gt;order_full_price.", currency:'USD'}"; ?&gt;); &lt;/script&gt; &lt;?php } else { $url = hikashop_completeLink('order&amp;task=show&amp;cid='.$this-&gt;order-&gt;order_id.'&amp;order_token='.$this-&gt;order-&gt;order_token); ?&gt; &lt;!-- Facebook Event snippet for Turkey Sales conversion page --&gt; &lt;script&gt; fbq('track', 'Purchase', &lt;?php echo "{value: ".$this-&gt;order-&gt;order_full_price.", currency:'USD'}"; ?&gt;); &lt;/script&gt; &lt;?php } echo '&lt;br/&gt;'.JText::sprintf('YOU_CAN_NOW_ACCESS_YOUR_ORDER_HERE', $url); } else { echo $this-&gt;html; } $this-&gt;nextButton = false;

Am i missing something obvious???

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI3LWNoZWNrb3V0Lzg5NDI1OS1mYWNlYm9vay1waXhlbC1maXJpbmctdHdpY2UtZm9yLXBheXBhbD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86587
- Thank you received: 14326
-
-

8 years 7 months ago [\#291365](#291365) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Facebook Pixel Firing Twice for Paypal](/forum/27-checkout/894259-facebook-pixel-firing-twice-for-paypal#291365 "-- HikaShop version -- : 3.2.2 -- Joomla version -- : 3.8.5  I've added my Facebook Tracking pixel to the top of the &quot;after&#95;end&quot; view. As you get redirected to Paypal, everything is fine. Normally, you would expect the pixel to fire once payment has been confirmed in paypal and after the redirection back to the thank you page (after&#95;end view file). However, if you cancel the paypal payment and return to the payment window on my site, the pixel fires....even though the &quot;after&#95;end&quot; file has not been called.  I've checked multiple times and the pixel is only on the &quot;end&quot; (for first data payment) and &quot;after&#95;end&quot; (for PayPal). Any reason why canceling the PayPal payment would result in the &quot;after&#95;end&quot; view file being called? Then, in the case where users canceled it and decided to pay with First Data, i see an instance where the pixel was fired twice for the same purchase. Obviously, this is showing false positives in my tracking statistics.  I should note that it's working properly for all confirmed orders, and seems to only be a problem on orders where customers cancel the payment and return to our website. The only reason I noticed this behavior is the Facebook conversion stats show I sold more than what I actually sold. The difference seems to be the canceled payment amount.")*

Hi,

You're basing yourself on whether $this-&gt;html is empty or not to display the facebook pixel.
However, it's possible that some credit card payment plugins (which display the credit card form directly during the checkout) fill the $this-&gt;html variable with their own thank you page instead of HikaShop's default one.

So instead of basing yourself on that variable, it would be better to check whether $this-&gt;order-&gt;order_payment_method == 'paypal'

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI3LWNoZWNrb3V0Lzg5NDI1OS1mYWNlYm9vay1waXhlbC1maXJpbmctdHdpY2UtZm9yLXBheXBhbD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[mojooutdoors-holden](/forum/user/12526-mojooutdoors-holden "View mojooutdoors-holden's Profile")**
- [![mojooutdoors-holden's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/12526-mojooutdoors-holden "View mojooutdoors-holden's Profile") Topic Author
- [ Offline](/forum/user/12526-mojooutdoors-holden)

Less More

- Posts: 303
- Thank you received: 18
-
-

8 years 7 months ago [\#291388](#291388) by [mojooutdoors-holden](/forum/user/12526-mojooutdoors-holden "View mojooutdoors-holden's Profile")  Replied by *[mojooutdoors-holden](/forum/user/12526-mojooutdoors-holden "View mojooutdoors-holden's Profile")* on topic *[Facebook Pixel Firing Twice for Paypal](/forum/27-checkout/894259-facebook-pixel-firing-twice-for-paypal#291388 "-- HikaShop version -- : 3.2.2 -- Joomla version -- : 3.8.5  I've added my Facebook Tracking pixel to the top of the &quot;after&#95;end&quot; view. As you get redirected to Paypal, everything is fine. Normally, you would expect the pixel to fire once payment has been confirmed in paypal and after the redirection back to the thank you page (after&#95;end view file). However, if you cancel the paypal payment and return to the payment window on my site, the pixel fires....even though the &quot;after&#95;end&quot; file has not been called.  I've checked multiple times and the pixel is only on the &quot;end&quot; (for first data payment) and &quot;after&#95;end&quot; (for PayPal). Any reason why canceling the PayPal payment would result in the &quot;after&#95;end&quot; view file being called? Then, in the case where users canceled it and decided to pay with First Data, i see an instance where the pixel was fired twice for the same purchase. Obviously, this is showing false positives in my tracking statistics.  I should note that it's working properly for all confirmed orders, and seems to only be a problem on orders where customers cancel the payment and return to our website. The only reason I noticed this behavior is the Facebook conversion stats show I sold more than what I actually sold. The difference seems to be the canceled payment amount.")*

I see. So would it be better to use the following on both the end and after_end view files?
Code:

&lt;php if ($this-&gt;order-&gt;order_payment_method == 'paypal' &amp;&amp; $this-&gt; order-&gt;order_status == 'confirmed') { &lt;!-- FB PIXEL --&gt; } elseif ($this-&gt;order-&gt;order_payment_method == 'firstdata' &amp;&amp; $this-&gt; order-&gt;order_status == 'confirmed'){ &lt;!-- FB PIXEL --&gt; } else { &lt;!-- DON'T USE PIXEL --&gt; } ?&gt;

Also be better to put this as the head of the file or within the " if(empty($this-&gt;html)) " conditional???

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI3LWNoZWNrb3V0Lzg5NDI1OS1mYWNlYm9vay1waXhlbC1maXJpbmctdHdpY2UtZm9yLXBheXBhbD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86587
- Thank you received: 14326
-
-

8 years 7 months ago [\#291409](#291409) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Facebook Pixel Firing Twice for Paypal](/forum/27-checkout/894259-facebook-pixel-firing-twice-for-paypal#291409 "-- HikaShop version -- : 3.2.2 -- Joomla version -- : 3.8.5  I've added my Facebook Tracking pixel to the top of the &quot;after&#95;end&quot; view. As you get redirected to Paypal, everything is fine. Normally, you would expect the pixel to fire once payment has been confirmed in paypal and after the redirection back to the thank you page (after&#95;end view file). However, if you cancel the paypal payment and return to the payment window on my site, the pixel fires....even though the &quot;after&#95;end&quot; file has not been called.  I've checked multiple times and the pixel is only on the &quot;end&quot; (for first data payment) and &quot;after&#95;end&quot; (for PayPal). Any reason why canceling the PayPal payment would result in the &quot;after&#95;end&quot; view file being called? Then, in the case where users canceled it and decided to pay with First Data, i see an instance where the pixel was fired twice for the same purchase. Obviously, this is showing false positives in my tracking statistics.  I should note that it's working properly for all confirmed orders, and seems to only be a problem on orders where customers cancel the payment and return to our website. The only reason I noticed this behavior is the Facebook conversion stats show I sold more than what I actually sold. The difference seems to be the canceled payment amount.")*

Hi,

You can even simplify your code and have: Code:

&lt;php if ($this-&gt; order-&gt;order_status == 'confirmed') { &lt;!-- FB PIXEL --&gt; } else { &lt;!-- DON'T USE PIXEL --&gt; } ?&gt;

since the order_status won't be confirmed for PayPal on the "end" view file and you customers won't be directed to "after_end" for firstdata.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI3LWNoZWNrb3V0Lzg5NDI1OS1mYWNlYm9vay1waXhlbC1maXJpbmctdHdpY2UtZm9yLXBheXBhbD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[mojooutdoors-holden](/forum/user/12526-mojooutdoors-holden "View mojooutdoors-holden's Profile")**
- [![mojooutdoors-holden's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/12526-mojooutdoors-holden "View mojooutdoors-holden's Profile") Topic Author
- [ Offline](/forum/user/12526-mojooutdoors-holden)

Less More

- Posts: 303
- Thank you received: 18
-
-

8 years 7 months ago [\#291445](#291445) by [mojooutdoors-holden](/forum/user/12526-mojooutdoors-holden "View mojooutdoors-holden's Profile")  Replied by *[mojooutdoors-holden](/forum/user/12526-mojooutdoors-holden "View mojooutdoors-holden's Profile")* on topic *[Facebook Pixel Firing Twice for Paypal](/forum/27-checkout/894259-facebook-pixel-firing-twice-for-paypal#291445 "-- HikaShop version -- : 3.2.2 -- Joomla version -- : 3.8.5  I've added my Facebook Tracking pixel to the top of the &quot;after&#95;end&quot; view. As you get redirected to Paypal, everything is fine. Normally, you would expect the pixel to fire once payment has been confirmed in paypal and after the redirection back to the thank you page (after&#95;end view file). However, if you cancel the paypal payment and return to the payment window on my site, the pixel fires....even though the &quot;after&#95;end&quot; file has not been called.  I've checked multiple times and the pixel is only on the &quot;end&quot; (for first data payment) and &quot;after&#95;end&quot; (for PayPal). Any reason why canceling the PayPal payment would result in the &quot;after&#95;end&quot; view file being called? Then, in the case where users canceled it and decided to pay with First Data, i see an instance where the pixel was fired twice for the same purchase. Obviously, this is showing false positives in my tracking statistics.  I should note that it's working properly for all confirmed orders, and seems to only be a problem on orders where customers cancel the payment and return to our website. The only reason I noticed this behavior is the Facebook conversion stats show I sold more than what I actually sold. The difference seems to be the canceled payment amount.")*

Now last question. Should this go at the very beginning like this:
Code:

&lt;php if ($this-&gt; order-&gt;order_status == 'confirmed') { &lt;!-- FB PIXEL --&gt; } else { &lt;!-- DON'T USE PIXEL --&gt; } ?&gt; &lt;?php /** * @package HikaShop for Joomla! * @version 3.2.2 * @author hikashop.com * @copyright (C) 2010-2018 HIKARI SOFTWARE. All rights reserved. * @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html */ defined('_JEXEC') or die('Restricted access'); ?&gt;&lt;?php $app = JFactory::getApplication(); $app-&gt;enqueueMessage( JText::_('THANK_YOU_FOR_PURCHASE') ); $user = JFactory::getUser(); if(!$user-&gt;guest){ $url = hikashop_completeLink('order&amp;task=show&amp;cid='.$this-&gt;order-&gt;order_id); ?&gt; &lt;?php }else{ $url = hikashop_completeLink('order&amp;task=show&amp;cid='.$this-&gt;order-&gt;order_id.'&amp;order_token='.$this-&gt;order-&gt;order_token); ?&gt; &lt;?php } $app-&gt;enqueueMessage(JText::sprintf('YOU_CAN_NOW_ACCESS_YOUR_ORDER_HERE',$url));

or within the if statement further down like this:
Code:

&lt;?php /** * @package HikaShop for Joomla! * @version 3.2.2 * @author hikashop.com * @copyright (C) 2010-2018 HIKARI SOFTWARE. All rights reserved. * @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html */ defined('_JEXEC') or die('Restricted access'); ?&gt;&lt;?php $app = JFactory::getApplication(); $app-&gt;enqueueMessage( JText::_('THANK_YOU_FOR_PURCHASE') ); $user = JFactory::getUser(); if(!$user-&gt;guest){ $url = hikashop_completeLink('order&amp;task=show&amp;cid='.$this-&gt;order-&gt;order_id); ?&gt; &lt;?php &lt;php if ($this-&gt; order-&gt;order_status == 'confirmed') { &lt;!-- FB PIXEL --&gt; } else { &lt;!-- DON'T USE PIXEL --&gt; } ?&gt; }else{ $url = hikashop_completeLink('order&amp;task=show&amp;cid='.$this-&gt;order-&gt;order_id.'&amp;order_token='.$this-&gt;order-&gt;order_token); ?&gt; &lt;php if ($this-&gt; order-&gt;order_status == 'confirmed') { &lt;!-- FB PIXEL --&gt; } else { &lt;!-- DON'T USE PIXEL --&gt; } ?&gt; &lt;?php } $app-&gt;enqueueMessage(JText::sprintf('YOU_CAN_NOW_ACCESS_YOUR_ORDER_HERE',$url));

**** ALSO, i noticed there isn't a closing php tag at the end of the default "after_end" file? Was this on purpose?

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI3LWNoZWNrb3V0Lzg5NDI1OS1mYWNlYm9vay1waXhlbC1maXJpbmctdHdpY2UtZm9yLXBheXBhbD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86587
- Thank you received: 14326
-
-

8 years 7 months ago [\#291453](#291453) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Facebook Pixel Firing Twice for Paypal](/forum/27-checkout/894259-facebook-pixel-firing-twice-for-paypal#291453 "-- HikaShop version -- : 3.2.2 -- Joomla version -- : 3.8.5  I've added my Facebook Tracking pixel to the top of the &quot;after&#95;end&quot; view. As you get redirected to Paypal, everything is fine. Normally, you would expect the pixel to fire once payment has been confirmed in paypal and after the redirection back to the thank you page (after&#95;end view file). However, if you cancel the paypal payment and return to the payment window on my site, the pixel fires....even though the &quot;after&#95;end&quot; file has not been called.  I've checked multiple times and the pixel is only on the &quot;end&quot; (for first data payment) and &quot;after&#95;end&quot; (for PayPal). Any reason why canceling the PayPal payment would result in the &quot;after&#95;end&quot; view file being called? Then, in the case where users canceled it and decided to pay with First Data, i see an instance where the pixel was fired twice for the same purchase. Obviously, this is showing false positives in my tracking statistics.  I should note that it's working properly for all confirmed orders, and seems to only be a problem on orders where customers cancel the payment and return to our website. The only reason I noticed this behavior is the Facebook conversion stats show I sold more than what I actually sold. The difference seems to be the canceled payment amount.")*

Hi,

You should put it at the beginning yes.
Ideally, it's best to put it just after the code: Code:

defined('_JEXEC') or die('Restricted access'); ?&gt;

because that code is a security feature of Joomla and help prevent against hacking attempts.

No closing PHP tag at the end is done on purpose.
If you happen to have extra characters after the last closing tag of a PHP file, these characters will end up in the output buffer of PHP. It might happen inadvertedly. And if you try to ouput headers after characters have been already ouput, it could generate errors and event break the downloads of files.
So it's better to never have closing PHP tags at the end of PHP files to avoid such risks. It's a good practice:
[ stackoverflow.com/questions/3219383/why-...-the-closing-php-tag](https://stackoverflow.com/questions/3219383/why-do-some-scripts-omit-the-closing-php-tag)

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI3LWNoZWNrb3V0Lzg5NDI1OS1mYWNlYm9vay1waXhlbC1maXJpbmctdHdpY2UtZm9yLXBheXBhbD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[mojooutdoors-holden](/forum/user/12526-mojooutdoors-holden "View mojooutdoors-holden's Profile")**
- [![mojooutdoors-holden's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/12526-mojooutdoors-holden "View mojooutdoors-holden's Profile") Topic Author
- [ Offline](/forum/user/12526-mojooutdoors-holden)

Less More

- Posts: 303
- Thank you received: 18
-
-

8 years 7 months ago [\#291490](#291490) by [mojooutdoors-holden](/forum/user/12526-mojooutdoors-holden "View mojooutdoors-holden's Profile")  Replied by *[mojooutdoors-holden](/forum/user/12526-mojooutdoors-holden "View mojooutdoors-holden's Profile")* on topic *[Facebook Pixel Firing Twice for Paypal](/forum/27-checkout/894259-facebook-pixel-firing-twice-for-paypal#291490 "-- HikaShop version -- : 3.2.2 -- Joomla version -- : 3.8.5  I've added my Facebook Tracking pixel to the top of the &quot;after&#95;end&quot; view. As you get redirected to Paypal, everything is fine. Normally, you would expect the pixel to fire once payment has been confirmed in paypal and after the redirection back to the thank you page (after&#95;end view file). However, if you cancel the paypal payment and return to the payment window on my site, the pixel fires....even though the &quot;after&#95;end&quot; file has not been called.  I've checked multiple times and the pixel is only on the &quot;end&quot; (for first data payment) and &quot;after&#95;end&quot; (for PayPal). Any reason why canceling the PayPal payment would result in the &quot;after&#95;end&quot; view file being called? Then, in the case where users canceled it and decided to pay with First Data, i see an instance where the pixel was fired twice for the same purchase. Obviously, this is showing false positives in my tracking statistics.  I should note that it's working properly for all confirmed orders, and seems to only be a problem on orders where customers cancel the payment and return to our website. The only reason I noticed this behavior is the Facebook conversion stats show I sold more than what I actually sold. The difference seems to be the canceled payment amount.")*

Thanks for the info. It works for first data, but it did not work for PayPal.

Therefore, I added it to the top of the "after_end" file. Seems to be firing properly for Paypal orders. Any reason why this would not work?
Code:

&lt;?php /** * @package HikaShop for Joomla! * @version 3.2.2 * @author hikashop.com * @copyright (C) 2010-2018 HIKARI SOFTWARE. All rights reserved. * @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html */ defined('_JEXEC') or die('Restricted access'); ?&gt; &lt;?php if ($this-&gt; order-&gt;order_status == 'confirmed') { ?&gt; &lt;!-- FB PIXEL --&gt; &lt;script&gt; fbq('track', 'Purchase', &lt;?php echo "{value: ".$this-&gt;order-&gt;order_full_price.", currency:'USD'}"; ?&gt;); &lt;/script&gt; &lt;?php } else { ?&gt; &lt;!-- DON'T USE PIXEL --&gt; &lt;?php } ?&gt; &lt;?php $app = JFactory::getApplication(); $app-&gt;enqueueMessage( JText::_('THANK_YOU_FOR_PURCHASE') ); $user = JFactory::getUser(); if(!$user-&gt;guest){ $url = hikashop_completeLink('order&amp;task=show&amp;cid='.$this-&gt;order-&gt;order_id); }else{ $url = hikashop_completeLink('order&amp;task=show&amp;cid='.$this-&gt;order-&gt;order_id.'&amp;order_token='.$this-&gt;order-&gt;order_token); } $app-&gt;enqueueMessage(JText::sprintf('YOU_CAN_NOW_ACCESS_YOUR_ORDER_HERE',$url));

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI3LWNoZWNrb3V0Lzg5NDI1OS1mYWNlYm9vay1waXhlbC1maXJpbmctdHdpY2UtZm9yLXBheXBhbD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86587
- Thank you received: 14326
-
-

8 years 7 months ago [\#291512](#291512) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Facebook Pixel Firing Twice for Paypal](/forum/27-checkout/894259-facebook-pixel-firing-twice-for-paypal#291512 "-- HikaShop version -- : 3.2.2 -- Joomla version -- : 3.8.5  I've added my Facebook Tracking pixel to the top of the &quot;after&#95;end&quot; view. As you get redirected to Paypal, everything is fine. Normally, you would expect the pixel to fire once payment has been confirmed in paypal and after the redirection back to the thank you page (after&#95;end view file). However, if you cancel the paypal payment and return to the payment window on my site, the pixel fires....even though the &quot;after&#95;end&quot; file has not been called.  I've checked multiple times and the pixel is only on the &quot;end&quot; (for first data payment) and &quot;after&#95;end&quot; (for PayPal). Any reason why canceling the PayPal payment would result in the &quot;after&#95;end&quot; view file being called? Then, in the case where users canceled it and decided to pay with First Data, i see an instance where the pixel was fired twice for the same purchase. Obviously, this is showing false positives in my tracking statistics.  I should note that it's working properly for all confirmed orders, and seems to only be a problem on orders where customers cancel the payment and return to our website. The only reason I noticed this behavior is the Facebook conversion stats show I sold more than what I actually sold. The difference seems to be the canceled payment amount.")*

Hi,

That's normal. You need to add the code to both end and after_end. If you only add it to end, it's normal that it would work for PayPal due to the way the system works.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI3LWNoZWNrb3V0Lzg5NDI1OS1mYWNlYm9vay1waXhlbC1maXJpbmctdHdpY2UtZm9yLXBheXBhbD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[mojooutdoors-holden](/forum/user/12526-mojooutdoors-holden "View mojooutdoors-holden's Profile")**
- [![mojooutdoors-holden's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/12526-mojooutdoors-holden "View mojooutdoors-holden's Profile") Topic Author
- [ Offline](/forum/user/12526-mojooutdoors-holden)

Less More

- Posts: 303
- Thank you received: 18
-
-

8 years 7 months ago [\#291559](#291559) by [mojooutdoors-holden](/forum/user/12526-mojooutdoors-holden "View mojooutdoors-holden's Profile")  Replied by *[mojooutdoors-holden](/forum/user/12526-mojooutdoors-holden "View mojooutdoors-holden's Profile")* on topic *[Facebook Pixel Firing Twice for Paypal](/forum/27-checkout/894259-facebook-pixel-firing-twice-for-paypal#291559 "-- HikaShop version -- : 3.2.2 -- Joomla version -- : 3.8.5  I've added my Facebook Tracking pixel to the top of the &quot;after&#95;end&quot; view. As you get redirected to Paypal, everything is fine. Normally, you would expect the pixel to fire once payment has been confirmed in paypal and after the redirection back to the thank you page (after&#95;end view file). However, if you cancel the paypal payment and return to the payment window on my site, the pixel fires....even though the &quot;after&#95;end&quot; file has not been called.  I've checked multiple times and the pixel is only on the &quot;end&quot; (for first data payment) and &quot;after&#95;end&quot; (for PayPal). Any reason why canceling the PayPal payment would result in the &quot;after&#95;end&quot; view file being called? Then, in the case where users canceled it and decided to pay with First Data, i see an instance where the pixel was fired twice for the same purchase. Obviously, this is showing false positives in my tracking statistics.  I should note that it's working properly for all confirmed orders, and seems to only be a problem on orders where customers cancel the payment and return to our website. The only reason I noticed this behavior is the Facebook conversion stats show I sold more than what I actually sold. The difference seems to be the canceled payment amount.")*

I think there may be some confusion. I added this to both files, but I was pointing out that if you add the pixel code to "after_end" after the following code Code:

defined('_JEXEC') or die('Restricted access'); ?&gt;

the pixel doesn't fire properly. I was forced to add it at the very beginning of the file for it to work properly.

However, i'm able to add it after this block in the "end" file.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI3LWNoZWNrb3V0Lzg5NDI1OS1mYWNlYm9vay1waXhlbC1maXJpbmctdHdpY2UtZm9yLXBheXBhbD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86587
- Thank you received: 14326
-
-

8 years 7 months ago [\#291561](#291561) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Facebook Pixel Firing Twice for Paypal](/forum/27-checkout/894259-facebook-pixel-firing-twice-for-paypal#291561 "-- HikaShop version -- : 3.2.2 -- Joomla version -- : 3.8.5  I've added my Facebook Tracking pixel to the top of the &quot;after&#95;end&quot; view. As you get redirected to Paypal, everything is fine. Normally, you would expect the pixel to fire once payment has been confirmed in paypal and after the redirection back to the thank you page (after&#95;end view file). However, if you cancel the paypal payment and return to the payment window on my site, the pixel fires....even though the &quot;after&#95;end&quot; file has not been called.  I've checked multiple times and the pixel is only on the &quot;end&quot; (for first data payment) and &quot;after&#95;end&quot; (for PayPal). Any reason why canceling the PayPal payment would result in the &quot;after&#95;end&quot; view file being called? Then, in the case where users canceled it and decided to pay with First Data, i see an instance where the pixel was fired twice for the same purchase. Obviously, this is showing false positives in my tracking statistics.  I should note that it's working properly for all confirmed orders, and seems to only be a problem on orders where customers cancel the payment and return to our website. The only reason I noticed this behavior is the Facebook conversion stats show I sold more than what I actually sold. The difference seems to be the canceled payment amount.")*

It should be the same. It's just a security check. Note that if you put it before, you of course have to put it before the &lt;?php tag or the code will break or be commented out based on where you place it exactly.

The following user(s) said Thank You: [mojooutdoors-holden](/forum/user/12526-mojooutdoors-holden "View mojooutdoors-holden's Profile")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI3LWNoZWNrb3V0Lzg5NDI1OS1mYWNlYm9vay1waXhlbC1maXJpbmctdHdpY2UtZm9yLXBheXBhbD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[mojooutdoors-holden](/forum/user/12526-mojooutdoors-holden "View mojooutdoors-holden's Profile")**
- [![mojooutdoors-holden's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/12526-mojooutdoors-holden "View mojooutdoors-holden's Profile") Topic Author
- [ Offline](/forum/user/12526-mojooutdoors-holden)

Less More

- Posts: 303
- Thank you received: 18
-
-

8 years 7 months ago [\#291784](#291784) by [mojooutdoors-holden](/forum/user/12526-mojooutdoors-holden "View mojooutdoors-holden's Profile")  Replied by *[mojooutdoors-holden](/forum/user/12526-mojooutdoors-holden "View mojooutdoors-holden's Profile")* on topic *[Facebook Pixel Firing Twice for Paypal](/forum/27-checkout/894259-facebook-pixel-firing-twice-for-paypal#291784 "-- HikaShop version -- : 3.2.2 -- Joomla version -- : 3.8.5  I've added my Facebook Tracking pixel to the top of the &quot;after&#95;end&quot; view. As you get redirected to Paypal, everything is fine. Normally, you would expect the pixel to fire once payment has been confirmed in paypal and after the redirection back to the thank you page (after&#95;end view file). However, if you cancel the paypal payment and return to the payment window on my site, the pixel fires....even though the &quot;after&#95;end&quot; file has not been called.  I've checked multiple times and the pixel is only on the &quot;end&quot; (for first data payment) and &quot;after&#95;end&quot; (for PayPal). Any reason why canceling the PayPal payment would result in the &quot;after&#95;end&quot; view file being called? Then, in the case where users canceled it and decided to pay with First Data, i see an instance where the pixel was fired twice for the same purchase. Obviously, this is showing false positives in my tracking statistics.  I should note that it's working properly for all confirmed orders, and seems to only be a problem on orders where customers cancel the payment and return to our website. The only reason I noticed this behavior is the Facebook conversion stats show I sold more than what I actually sold. The difference seems to be the canceled payment amount.")*

I agree. Still didn't work when added after that security check. For now, i just added it at the beginning of the file with proper php opening and closing tags.

Thanks again!

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI3LWNoZWNrb3V0Lzg5NDI1OS1mYWNlYm9vay1waXhlbC1maXJpbmctdHdpY2UtZm9yLXBheXBhbD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

Board Categories HikaShop Install &amp; Update Product &amp; Category Display Content Creation Sales and Orders Orders management Reports &amp; Statistics Customers Checkout Payment Methods Shipping Methods Import &amp; Export (CSV, XLS…) Specific Features Affilation Taxes Wishlist Vote Carousel &amp; Slider Mass Actions Filters &amp; Search Discount &amp; Coupon Feature Request Integrations Showcase General Talk about HikaShop Development HikaShop 3.0 Beta Translation Commercial Jobs HikaShop Components HikaMarket Market: Feature requests Market: How to? Market: Bug Report HikaSerial General talk about HikaSerial Serial: Bug Report Serial: How to? Support en Français de HikaSerial (French Support) HikaSubscription HikaAuction Auction: Feature requests Auction: How to? Auction: Bug report Hikashop around the world Support en Français (French Support) Russian FAQ. Курс выживания с Hikashop. Частые вопросы и о Расширения Hikashop Наши сайты на Hikashop 日本語版サポート(Japanese Support) Thai German Archives Bug Report How to?

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.100 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)
