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

Start Selling With SureCart Today

Start for Free – No Credit Card Required

Trusted by Thousands of Businesses
Trusted by Thousands of Businesses
Start for Free. No Credit Card Required
World Class Support Team
Scroll to Top