Facebook Purchase Conversion Pixel

Hello Guys,

I've been looking for a solution to this for several hours but I'm still lost because all I can find is outdated or incomplete information. The issue is that I need to track conversions with Facebook Pixel but can't find the place for the pixel to track purchase conversions. It has been very frustrating. Any ideas? Thanks.

  • Adam Czajczyk
    • Support Gorilla

    Hello Javier,

    I hope you're well today and thank you for your question!

    The MarketPress eCommerce plugin currently doesn't support Facebook Pixel out of the box and that's why there's no place/option to add it there.

    I think though that since the FB Pixel should be placed on some kind of "purchase confirmation"/"thank you" page and there's no such one in MarketPress, the most logical place would be the "order status" page that's displayed to the user after successful purchase.

    However, this page is served to the user in other cases as well so we'd need to include the pixel only if the page was displayed as a purchase confirmation.

    The issue though is that I'm not yet sure what hook/filter could be used for this. I have asked MarketPress developers for help on this and when I only get to know anything I'll update this thread with information so please keep an eye on it.

    Best regards,

  • Javier
    • WPMU DEV Initiate

    Thanks for the reply Adam.

    I found the code where the pixel should go but I don't know exactly what to add to do it right. Below is the code from the "marketpress/includes/common/class-mp-order.php"

    		 * Fires when an order is created
    		 * @since 3.0
    		 * param MP_Order $this The current order object.
    		do_action( 'mp_order/new_order', $this );
    		do_action( 'mp_product_created', $this->ID );//support for older integrations
    		// Empty cart
    		// Remove session variables
    		if ( mp_get_session_value( 'mp_shipping_info' ) ) {
    			foreach ( $_SESSION['mp_shipping_info'] as $key => $val ) {
    				switch ( $key ) {
    					case 'shipping_option' :
    					case 'shipping_sub_option' :
    					case 'shipping_cost' :
    						unset( $_SESSION[ $key ] );
    		// Send new order email
    		// If paid and the cart is only digital products mark it shipped
    		if ( $paid && $cart->is_download_only() ) {
    			$this->change_status( 'order_shipped', true );
    		// Cache the ID for later use
    		wp_cache_set( 'order_object', $this, 'mp' );
  • Adam Czajczyk
    • Support Gorilla

    Hello Javier!

    Thank you for your replay!

    It seems you're on a right track. I just got a message from one of our developers and although he confirmed that there's no "out of the box" hook/place in MarketPress to use Facebook Pixel, it may be best to go this way:

    1. hook to the "mp_order/new_order" action to store some (unique) cookie:

    function my_fb_pixel_cookie() {
    // generate unique value for a cookie here
    // and save cookie

    2. Then hook in a similar fashion to the "wp_head" hook and
    - check the cookie
    - if it exists print out the script and delete it.

    That would require some custom development though. If you feel like giving it a try yourself, please feel free to ask questions "on the way" if you have any, however if you need it developed for you you may want to ask on our "Jobs & Pros" job board (please note: no WPMU DEV staff involved!) here:


    Best regards,

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.