Facebook Pixel Integration - SureCart

No results found. Try again with different words?

Search must be at least 3 characters.

Facebook Pixel Integration

You can integrate SureCart purchases with Facebook Pixel. To do this, you will want to add a bit of custom code to your site. The easiest way to do this is to use a free code snippets plugin, though you can do this in your theme or with a separate plugin too.

Our checkout component emits an event called scOrderPaid, which happens when a checkout is paid. This lets you listen for the event, and look at the checkout data to send to facebook pixel. An easy way to do this is to add this to your site’s footer. Here’s an example:

add_action(
    'wp_footer',
    function() {  ?>
        <script>
            document.querySelector('sc-checkout').addEventListener('scOrderPaid', function(e) {
                const checkout = e.detail;
                if( checkout && checkout.amount_due ) {
                    fbq('track', 'Purchase', {
                        currency: checkout.currency, 
                        value: checkout.amount_due / 100,
                        email: checkout.email,
                        name: checkout.name
                    });
                }
            });
        </script>
        <?php
    }
);

Was this article helpful?


Did not find a solution? We are here to help you succeed.

Try SureCart today

And experience the better way to sell on your website

30-Day money-back guarantee
24/7 world class support team
Safe & secure online payment

Remind me about SureCart HUGE Black Friday Sale

Scroll to Top