stape-io / gtm-server-side-wordpress-plugin

Google Tag Manager Server-Side plugin for WordPress
https://stape.io/how-to-add-google-tag-manager-server-side-container-to-wordpress/
GNU General Public License v2.0
15 stars 2 forks source link

Purchase event is delayed #8

Closed YoanRouleau closed 7 months ago

YoanRouleau commented 7 months ago

Hi there,

I'm noticing delays on my purchase event trigger. Within the GTM debugger, I see that all the events are fired correclty, except for the purchase one. The datalayer.push is fired, but on the next page visit right after the order-received page.

On the following exemple, I successfully ordered on my website, and went back on the homepage (because I didn't see any purchase event after placing my order):

Capture d’écran 2023-11-21 à 17 23 26

Have you done some tweeks or changes concerning the purchase event trigger condition??

YoanRouleau commented 7 months ago

While I was trying to find out where that could come from, I noticed that this bad scenario only occurs when I choose to pay using by client's bank payment plugin.

alexbub commented 7 months ago

Hi @YoanRouleau ,

Thank you for your interest in Stape!

We have not previously received reports of similar issues from other users and it seems the problem is indeed related to how your bank payment plugin works. Can you please provide which plugin you use for this? We will add this to our backlog and if we get more similar complaints we will add support for it.

YoanRouleau commented 7 months ago

Hi Alex!

Thank your for your fast answer. :) We've been using Up2pay E-transactions: https://fr.wordpress.org/plugins/e-transactions-wc/ I also contacted the website's dev team and asked them to update Woocommerce and E-transactions, so we can check what is not causing this bug more accurately.

YoanRouleau commented 7 months ago

We've updated Woocommerce to its latest version and tested the purchase event again. It didn't fix the bug, sadly. :/

YoanRouleau commented 7 months ago

Hello!

I just wanted to know if you'd have any news regarding my previous report.

Best,

alexbub commented 7 months ago

Hello,

As I wrote earlier, we have not received any such complaints from other users so this is definitely an individual issue or a nuance of how your 'e-transactions' plugin works. In our backlog we have the task to test the data layer operation with this plugin, but due to high workload with other tasks unfortunately I don't think we will be able to address it in the next 3-4 months. I can recommend in your case just for data layer to use any other plugin.

YoanRouleau commented 7 months ago

Alright! Thanks for your time. :) We'll check what we can do on our end.

YoanRouleau commented 7 months ago

Solved it myself. Letting you know that in class GTM_Server_Side_Event_Purchase https://github.com/stape-io/gtm-server-side-wordpress-plugin/blob/88904eb4a2873d151fbcecc753a0bd07dd947b67/includes/class-gtm-server-side-event-purchase.php#L42

... the woocommerce_new_order hook is also triggered during the "order-pay" step. This comes to be problematic when a payment gateway isn't direclty accessed straight on the purchase button click. e.g. When using Paypal, you click on purchase and you're sent to paypal without any "intermediate" step.

I realize that this must only be the case on a few payment plugins, but I would recommend switching to an "order-status" check when firing the datalayer.push("purchase").

alexbub commented 7 months ago

Hey @YoanRouleau,

Thank you so much for letting us know and sorting out the problem. I have added this solution to the backlog. We will test and most likely use it in the next update.