Search code examples
facebookcs-cart

Adding Facebook Pixel Conversion Code in CS-Cart 3


I would like to add a tracking pixel on the checkout confirmation page in the <head> section as Facebook requires to. I use CS-Cart 3.0.6

So far, with what I read on Google and forums, I have to add the script in the

/skins/name_of_the_active_skin/customer/addons/my_changes/hooks/checkout/ directory.

So did I, with the namefile of meta.post.tpl:

{hook name="checkout:order_confirmation"}
    {literal}
    <!-- Facebook Conversion Code for Paid -->
    <script>(function() {
    var _fbq = window._fbq || (window._fbq = []);
    if (!_fbq.loaded) {
    var fbds = document.createElement('script');
    fbds.async = true;
    fbds.src = '//connect.facebook.net/en_US/fbds.js';
    var s = document.getElementsByTagName('script')[0];
    s.parentNode.insertBefore(fbds, s);
    _fbq.loaded = true;
    }
    })();
    window._fbq = window._fbq || [];
    window._fbq.push(['track', '928383727823', {'value':'{/literal}{$order_info.total}{literal}','currency':'USD'}]);
    </script>
    <noscript><img height="1" width="1" alt="" style="display:none" src="https://www.facebook.com/tr?ev=8283838383832&amp;cd[value]={/literal}{$order_info.total}{literal}&amp;cd[currency]=USD&amp;noscript=1" /></noscript>
    {/literal}
{/hook}

It does not work. Is it the file name ? Do you know how to achieve this ?


Solution

  • Finally, as I couldn't find out how to make this work, I chose not to use the hooking system (that should be nice and flexible) and modified the file skins/basic/customer/meta.tpl with the js snipet between this condition:

    {if $smarty.request.dispatch=='checkout.complete'}
    ...code...
    {/if}
    

    I guess this will help some CS-Cart users.