Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

[Addon] Facebook Pixel


BrockleyJohn

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');

 

Link to comment
Share on other sites

  • 1 year later...

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).

Contact me for work on updating existing stores - whether to Phoenix or the new osC when it's released.

Looking for a payment or shipping module? Maybe I've already done it.

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

Link to comment
Share on other sites

  • 2 months later...
  • 2 months later...
  • 2 months later...
  • 5 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...