X-Cart:How to Add Facebook Pixel Code to X-Cart Pages
This article describes how to add Facebook Pixel code to the pages of X-Cart 4 Classic.
Please be aware that, with X-Cart 4.7.x 4.6.6 4.5.5 4.4.5, you can set up Facebook Pixel without custom programming - by using the module Facebook E-Commerce
Step-by-step guide
Locate the file skin/common_files/customer/service_head.tpl in your X-Cart folder and open it in X-Cart's Template Editor or a text editor of your choice.
Add the following code to the very end of the file:
<script type="text/javascript"> //<![CDATA[ {literal} !function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod? n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n; n.push=n;n.loaded=!0;n.version='2.0';n.agent='plxcart';n.queue=[];t=b.createElement(e);t.async=!0; t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window, document,'script','https://connect.facebook.net/en_US/fbevents.js'); {/literal} fbq('init', '{$config.Facebook_Ecommerce.facebook_ecomm_pixel_id|escape:"javascript"}'); // Insert your pixel ID here. fbq('track', 'PageView'); //]]> </script> <noscript><img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id={$config.Facebook_Ecommerce.facebook_ecomm_pixel_id|escape:"html"}&ev=PageView&noscript=1"/></noscript> <!-- End Facebook Pixel Code -->
Insert your pixel ID instead of {$config.Facebook_Ecommerce.facebook_ecomm_pixel_id|escape:"javascript"} in the code above.
Save the changes and re-generate the X-Cart cache to make the changes active.
The command fbq('track', 'PageView'); used in the code above will create a standard event on the Facebook end.
It is also possible to add Facebook pixel ID by running the following SQL query in the Patch/Upgrade Center of the store Admin area:
INSERT INTO xcart_config SET name='facebook_ecomm_pixel_id', comment='Facebook Pixel ID', value='', category='Facebook_Ecommerce', orderby='20', type='trimmed_text', defvalue='', variants='', validation='' ON DUPLICATE KEY UPDATE orderby=orderby;
where value '' should be completed with your actual Facebook pixel ID value.
Fixing the error 'The pixel for this event is not paired with a product catalog. This may cause your catalog features and dynamic ads to not work properly.'
Try this https://www.facebook.com/business/help/1044262445604547