Facebook pixel

#288945
  • Resolved Ivo Kittel
    Rank Math free

    Hi,
    Does Rank Math solve the issue of missing product microdata when trying to sync products from a WooCommerce shop to the FB shop? I’m using the free version of RM but am still getting an error and missing the price and ID of products when trying to connect to FB using the pixel.

Viewing 8 replies - 1 through 8 (of 8 total)
  • Hello,

    Thanks for contacting us and sorry for any inconvenience that might have been caused due to that.

    You can use the filter given below in your theme’s functions.php file:

    add_action( 'rank_math/head', function() {
        if ( ! is_product() ) {
            return;
        }
        global $post;
        echo '<meta property="product:retailer_item_id" content="' . $post->ID . '" />';
    }, 99 );

    This should print an ID of the product in the metadata and Facebook should be able to see it correctly.

    For the price, Rank Math automatically adds a price OpenGraph tag to the products. Can you please confirm if you are using variable products?

    Looking forward to helping you.

    Hi, thank you for the reply. The snippet provided did the trick for the ID.
    Yes, I am using variable products.

    Hello,

    If you want to force the price meta tag to appear on variable products you can modify and use the following filter:

    add_filter( "rank_math/opengraph/facebook/product_price_amount", function( $content ) {
        // Do some checks to see if the product is variable and output the price you wish
        return 'your_price_here';
    });

    Let us know how that goes. Looking forward to your update.

    Thanks.

    Hi,
    Thanks, but how would I modify that to show the different variable prices?

    Hi, are you perhaps able to expand on your suggestion as to how to do this 🙏? I have been searching and searching for nearly 2 days now trying to figure this out. I can’t believe that it is so complicated to get WC products to sync up with FB pixel, when there must be so many people with the same issue.

    Hello,

    The meta tag for the price amount can only have a single value so you’ll need to get the ID of one of the variations that you wish to display the price and then query the database to get the price of that variation with the following code:

    
    get_post_meta('variation_ID_here', '_price', true);
    

    Hope this help get you to the final solution for this situation.

    Don’t hesitate to get in touch if you have any other questions.

    Hi Miguel,
    Thanks. But unfortunately my development skills are not advanced enough to hash this out. I was so hoping that Rank Math would be able to assist with this and sort it out (having initially tried Yoast), but no luck. We will have to setup a new pixel and make use of the Facebook partner platform to sync up the products (which is what we were trying to avoid).

    Nigel
    Rank Math business

    Hello,

    Thank you for your patience as we address your issue. Unfortunately, the level of custom code you need is beyond the scope of our support. I hope you find a solution that delivers the results you need.

    If you have questions, do not hesitate to ask. We are here to help.

    Hello,

    Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.

    If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.

    Thank you.

Viewing 8 replies - 1 through 8 (of 8 total)

The ticket ‘Facebook pixel’ is closed to new replies.