How To Include Facebook Pixel Code On WooCommerce Pages

Here’s this nifty snippet that allows you to add any custom code to WooCommerce pages be it Facebook pixel tracking code or any other custom code.

You can put this code into your functions.php file.

<?php

add_action( 'wp_head', 'my_wooc_fb_pixel_code' );

function my_wooc_fb_pixel_code() {

    if ( !in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
        return;
    }

    if(is_woocommerce() || is_product_category() || is_product_tag() || is_cart() || is_shop() || is_checkout()) { ?>
    paste your Facebook pixel code here
    <?php
    }
}

Need further help? Say hello.

Divi WordPress Theme