Hi Themeco, big problem for us with our Facebook Campaigns.
When a Layout is assigned to a Single Product, the ViewContent event is not fired from facebook pixel.
This means no retargeting is possible.
When the layout is deactivated and reverted to woocommerce’s standard one, the ViewContent is fired.
The Facebook-for-woocommerce plugin injects the following code via hooks:
// ViewContent for individual products
add_action( 'woocommerce_after_single_product', [ $this, 'inject_view_content_event' ] );
add_action( 'woocommerce_after_single_product', [ $this, 'maybe_inject_search_event' ] );
add_action( 'woocommerce_after_shop_loop', [ $this, 'inject_view_category_event' ] );
add_action( 'pre_get_posts', [ $this, 'inject_search_event' ] );
add_filter( 'woocommerce_redirect_single_search_result', [ $this, 'maybe_add_product_search_event_to_session' ] );
The problem is, woocommerce_after_single_product hook is missing if a custom layout is assigned, so no ViewContent code is injected and no event is tracked.
We temporary solved this overwriting files in the plugin and using woocommerce_after_add_to_cart_form (which is present in our single product layout, thanks to the “Add to Cart Form” element) instead of woocommerce_after_single_product.
Is there a way to avoid applying a layout, with it “removing” the standard woocommerce hooks?
Or is there a way to add hooks to a custom Layout in Pro?
Thanks!
UPDATE: Same thing happens with Google Analytics 4 - the view_item event is not fired when custom layout is assigned