Jump to content
BrockleyJohn

[Addon] Facebook Pixel

Recommended Posts

@BrockleyJohn Thank you for the app. I noticed that the "InitiateCheckout" is not included so I added to my site and here are the additions if you or someone can benefit from it.

in includes/modules/header_tags/ht_facebook_pixel.php near line 48 I replaced 

    function execute() {
    	global $PHP_SELF, $oscTemplate, $customer_id, $currencies, $order, $product_check, $currency;

with 

    function execute() {
		global $PHP_SELF, $oscTemplate, $customer_id, $currencies, $order, $product_check, $currency, $cart_total;

 

near line 159 replaced

				} elseif ( basename($PHP_SELF) == 'advanced_search_result.php' && MODULE_HEADER_TAGS_FB_SEARCH_EVENTS == 'True' && isset($_GET['keywords']) ) {
					$footer .= '<!-- Facebook Event Tracking -->			
<script>
  fbq(\'track\', \'Search\', {
    search_string: \'' . $_GET['keywords'] . '\',
  });
</script>
<!-- End Facebook Event Tracking -->
';						
					$oscTemplate->addBlock($footer, 'footer_scripts');
				}

with 

				} elseif ( basename($PHP_SELF) == 'advanced_search_result.php' && MODULE_HEADER_TAGS_FB_SEARCH_EVENTS == 'True' && isset($_GET['keywords']) ) {
					$footer .= '<!-- Facebook Event Tracking -->			
<script>
  fbq(\'track\', \'Search\', {
    search_string: \'' . $_GET['keywords'] . '\',
  });
</script>
<!-- End Facebook Event Tracking -->
';						
					$oscTemplate->addBlock($footer, 'footer_scripts');
				} elseif ( basename($PHP_SELF) == 'checkout_shipping.php' && MODULE_HEADER_TAGS_FB_INITIATE_CHECKOUT_EVENT == 'True' && $cart_total > 0 ) {
					$footer .= '<!-- Facebook Event Tracking -->			
<script>
  fbq(\'track\', \'InitiateCheckout\');
</script>
<!-- End Facebook Event Tracking -->
';						
					$oscTemplate->addBlock($footer, 'footer_scripts');
				}

 

Replaced

                     'MODULE_HEADER_TAGS_FB_PRODUCT_VIEWS' => array('title' => 'Product Views',
                                                                     'desc' => 'Do you want to track product views?',
                                                                    'value' => 'True',
                                                                 'set_func' => 'tep_cfg_select_option(array(\'True\', \'False\'), '),

 

with

                     'MODULE_HEADER_TAGS_FB_PRODUCT_VIEWS' => array('title' => 'Product Views',
                                                                     'desc' => 'Do you want to track product views?',
                                                                    'value' => 'True',
                                                                 'set_func' => 'tep_cfg_select_option(array(\'True\', \'False\'), '),
           'MODULE_HEADER_TAGS_FB_INITIATE_CHECKOUT_EVENT' => array('title' => 'Initiate Checkout',
                                                                     'desc' => 'Do you want to track checkout initiations?',
                                                                    'value' => 'True',
                                                                 'set_func' => 'tep_cfg_select_option(array(\'True\', \'False\'), '),

 

 

Meanwhile, in template_bottom.php before

echo $oscTemplate->getBlocks('footer_scripts');

I added 

 $cart_total = $cart->show_total(); 
 if (!tep_session_is_registered('cart_total')) 
    tep_session_register('cart_total');

 

Share this post


Link to post
Share on other sites

I have just uploaded v1.4 to the addons section.

This is a security update - all addon users should apply it. PM me if you want details of what the problem is (not necessary to apply the fix).


For a new install or if your store isn't mobile-friendly, get the community-supported responsive osCommerce (Phoenix).

here: on the official osc download page

Working on generalising bespoke solutions for Quickbooks integration, Easify integration and pay4later (DEKO) integration at 2.3.x

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×