• Resolved dorefresh

    (@dorefresh)


    Hi,

    I might be doing something wrong, but I think there is a bug in the plugin. I had an issue with one client as the events were not firing correctly.

    I discovered that events are deferred in case redirect to cart after adding product to cart is on. This code is in facebook-commerce-pixel-event.php, function inject_event on line 287.

    This is causing to fire AddToCart event correctly. However, other events like InitiateCheckout, ViewContent, Purchase,… are delayed until next pageload.
    For example, InitiateCheckout is fired when order is placed, Purchase is fired on next pageload after order thank you page is shown,…

    I can see the same behaviour with other websites I manage.

    Kind Regards,
    Lubos

Viewing 7 replies - 1 through 7 (of 7 total)
  • Hi @dorefresh,

    Thank you for reaching out to us and for your detailed explanation of the issue you’re experiencing with the Facebook for WooCommerce plugin. It seems like the events are being deferred when the ‘redirect to cart after adding product to cart’ option is enabled. This is causing the AddToCart event to fire correctly, but other events like InitiateCheckout, ViewContent, and Purchase are delayed until the next page load.

    Here are a few steps we can take to troubleshoot this issue:

    1. Update the Plugin: Ensure that you’re using the latest version of the Facebook for WooCommerce plugin. Updates often include bug fixes that might resolve the issue you’re experiencing. You can check for updates from your WordPress dashboard by navigating to ‘Plugins’ > ‘Installed Plugins’.
    2. Check for Plugin Conflicts: Sometimes, other plugins can interfere with the functionality of the Facebook for WooCommerce plugin. Try deactivating other plugins temporarily to see if the issue persists. If the issue is resolved, reactivate the plugins one by one to identify which one is causing the conflict.
    3. Remove the Plugin: If the issue persists, you might want to consider removing the plugin and adding it back again.

    If you’re still experiencing the issue after trying these steps, it might be a bug in the plugin itself. In that case, please share with us the System Status Report which you can find via WooCommerce > Status > Get system report > Copy for support. You could copy and paste your reply here or paste it via https://gist.github.com/ and send the link here.

    I hope this helps! If you have any other questions or if there’s anything else we can assist you with, please don’t hesitate to let us know.

    We haven’t heard back from you in a while, so I’m going to mark this as resolved – we’ll be here if and/or when you are ready to continue.

    Thread Starter dorefresh

    (@dorefresh)

    Hi,

    I am certain it is a bug.
    Here is the system report.
    https://gist.github.com/ljezik/b777162198b26e1b9fc3a047ed42cd7f

    Thanks!

    Hi @dorefresh,

    Thanks for sharing the system status report! I noticed you’re using an outdated version of WooCommerce.

    As a first step, I’d recommend updating WooCommerce to the latest version and running a conflict test to see if you are able to observer the same behavior.

    Thread Starter dorefresh

    (@dorefresh)

    Hi,

    It is still the same with all plugins updated to the latest version. I believe that the below function in facebook-commerce-pixel-event.php is the problem. It defers all the events, not only AddToCart.

    public function inject_event( $event_name, $params, $method = 'track' ) {
    			// If we have add to cart redirect enabled, we must defer the events to render them the next page load.
    			$should_defer = 'yes' === get_option( 'woocommerce_cart_redirect_after_add', 'no' );
    			if ( WC_Facebookcommerce_Utils::isWoocommerceIntegration() ) {
    				$code = $this->get_event_code( $event_name, self::build_params( $params, $event_name ), $method );
    
    				if ( $should_defer ) {
    					WC_Facebookcommerce_Utils::add_deferred_event( $code );
    				} else {
    					WC_Facebookcommerce_Utils::wc_enqueue_js( $code );
    				}
    			} else {
    				printf( $this->get_event_script( $event_name, self::build_params( $params, $event_name ), $method ) ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
    			}
    		}

    Hi @dorefresh,

    Thank you for providing more details.

    If you believe it is a bug, you could create a bug report directly on our GitHub repository here.

    However, let’s thoroughly troubleshoot this issue together before we report it to the developer team. This way, we can provide them with as much information as possible to help them debug the issue further.

    I’ve reviewed your site’s system status reports. I noticed you’re currently using WPRocket and have overridden some templates, such as the cart and checkout page. However, these templates are outdated and incompatible with the latest version of WooCommerce.

    To resolve this, could you kindly update these custom templates to ensure they’re compatible with the latest WooCommerce version? Afterward, I suggest excluding the WooCommerce Cart and checkout page from WPRocket. Alternatively, if feasible, you may temporarily disable WPRocket to see if that resolves the issue.

    Let us know how that goes. Looking forward to helping you.

    Hi there. Just checking, are there any updates on this?

    We haven’t heard back from you in a while, so I’m going to mark this as resolved – we’ll be here if and/or when you are ready to continue.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Delayed events injection’ is closed to new replies.