Difference between revisions of "X-Cart:How to Add Facebook Pixel Code to X-Cart Pages"
(Created page with "This article describes how to add Facebook Pixel code to the pages of X-Cart 4 Classic. Please be aware that, starting with X-Cart 4.7.x, you can set up Facebook Pixel withou...") |
(→Fixing the error 'The pixel is not paired with any product catalog. A relationship between a pixel and product catalog must be specified.') |
||
(5 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
This article describes how to add Facebook Pixel code to the pages of X-Cart 4 Classic. | This article describes how to add Facebook Pixel code to the pages of X-Cart 4 Classic. | ||
− | Please be aware that, | + | 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 [https://secure.x-cart.com/customer.php?folder_id=318189&area=filearea&target=files_explorer&subject=536931379 Facebook E-Commerce] |
==Step-by-step guide== | ==Step-by-step guide== | ||
Line 8: | Line 8: | ||
Add the following code to the very end of the file: | Add the following code to the very end of the file: | ||
<pre> | <pre> | ||
− | <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 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> | <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 --> | <!-- End Facebook Pixel Code --> | ||
</pre> | </pre> | ||
− | Insert your pixel ID instead of ''' | + | 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. | Save the changes and re-generate the X-Cart cache to make the changes active. | ||
Line 28: | Line 35: | ||
where '''<nowiki>value ''</nowiki>''' should be completed with your actual Facebook pixel ID value. | where '''<nowiki>value ''</nowiki>''' should be completed with your actual Facebook pixel ID value. | ||
− | See [[X-Cart:Applying_Patches#Applying_SQL_Patches | Applying SQL Patches]]. | + | See [[X-Cart:Applying_Patches#Applying_SQL_Patches | Applying SQL Patches]] |
+ | |||
+ | ==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 | ||
+ | |||
+ | |||
+ | [[Category:X-Cart developer guide]] |
Latest revision as of 09:48, 8 July 2019
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