Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EVENT PURCHASE DON'T FIRE ON LINK ORDER PAY WOOCOMMERCE #328

Open
giuseppecaiazza16 opened this issue Feb 28, 2024 · 24 comments
Open

EVENT PURCHASE DON'T FIRE ON LINK ORDER PAY WOOCOMMERCE #328

giuseppecaiazza16 opened this issue Feb 28, 2024 · 24 comments

Comments

@giuseppecaiazza16
Copy link

giuseppecaiazza16 commented Feb 28, 2024

Hi @duracelltomi, I'm opening this issue to you because I noticed that when I send the link for the order balance like this link:
https://diventapilota.wecanrace.it/checkout/order-pay/154144/?pay_for_order=true&key=wc_order_wAIvqvnxiO0oH
the purchase event is not triggered and I lose tracking of these orders that are tracked.

@duracelltomi
Copy link
Owner

Hi,

The purchase event will be fired when the payment is done and the order received page is shown with the thank you message.

@giuseppecaiazza16
Copy link
Author

giuseppecaiazza16 commented Mar 4, 2024

Hi @duracelltomi, yes, in fact, this is why I linked you to the page first, and as per proof that you can do it too and as per the screen and video recording, after I have made the purchase the purchase event does not trigger https://www.loom.com/share/efc29a3a84c04953952094f9b94436b4?sid=357f1ea1-db31-49c1-89cb-01cac08d4db2

@SirRahikkala
Copy link

I will add my voice here too. The purchase tracking is not working and the Wordpress plugin page has several people in panic mode due this.

@duracelltomi
Copy link
Owner

Hi,

When I place a test order on my dev site and visit the order pay page and select an option, I can see the purchase event.
I guess your issues are related to other plugin users where one payment method executes accidentally some GTM4WP code that marks your order as being tracked with a purhcase event before the thank you page is shown.

I have a draft solution for that, if any of you has a safe test site where one PHP file in GTM4WP can be replaced to test a possible fix, we could see if this solves your problem. Without this, you can also test if you have a similar problem if you turn on "Do not flag orders as being tracked" option in GTM4WP under Integration->WooCommerce

@SirRahikkala
Copy link

@morvy
Copy link
Contributor

morvy commented Mar 26, 2024

@SirRahikkala 2 of 3 topics you mention are not related, they are just lazy users who don't read update for breaking changes and don't update their GTM as instructed here: https://gtm4wp.com/announcements/be-prepared-to-big-changes-in-gtm4wp-v1-20.html

@duracelltomi
Copy link
Owner

What I am testing currently is to remove the purchase tracking when detecting the is_order_received() tag and only fire on the woocommerce_thankyou action. Hopefully it will be really only fired once when the thank you page is being generated.

@duracelltomi
Copy link
Owner

I need someone who can test a bigger change in GTM4WP on a test instance so that it does not break any live site:

integration/woocommerce.php has to be replaced with this:
https://raw.githubusercontent.com/duracelltomi/gtm4wp/master/integration/woocommerce.php

What does this do?

Since the beginning, GTM4WP fired the purchase event during page load when the WooCommerce tag is_order_received() returned true (thus, the user is on the order received page either after the checkout or after the order pay page).

For some reasons, this does not work in more and more cases.

This test moves purchase tracking into another WooCommerce hook: woocommerce_thankyou
This is a template action fired during generating the order received page. As far as I can see, it is widely supported even by 3rd party customization plugins. If GTM setup is configured to fire any tracking on the purchase event (including the Google Ads conversion tag), there is no need to change your GTM setup.

What is moving with this change:

  • GA4 purchase data
  • Google Ads new customer data
  • orderData that can be used broadly, my only real life example is fueling Google Ads enhanced conversions with hash data

@Blueboots
Copy link

I think I have the same issue. The site I deal with has very low frequency of purchases, so I wasn't sure for a while, but now I am convinced.
My issue started around the time of implementing the Google consent mode changes. Could it be associated in any way with when or how GA4 tags are fired based on consent, thus only being a problem for some people?
I don't have easy access to the checkout process so I can't do any deep testing to follow up this thought.

@duracelltomi
Copy link
Owner

@Blueboots the same issue (missing purchase conversions) can be caused by many factors. When you started seeing this after implementing CoMo, it could mean that there is a problem with your CoMo setup. When you send the purchase event with analytics consent denied, it will be only used for modelling purposes. This could be also the case when the purchase event is fired too early, before the update consent command and executed with the default consent flags that is usually denied by default.

@Blueboots
Copy link

Blueboots commented Apr 8, 2024

Agreed it could be many things, but part of my Consent setup involved upgrading to GTM4WP v1.20.1 to fix the bug of the GTM container still appearing when off and with console error messages off. So my purchases stopping correlates with updating to v1.20 AND my consent implementation. Unfortunately I cannot dig very deep in the actual checkout to debug, but as you mentioned that the purchase event fired during page load, and some (but not all) people have been adjusting when their GA4 tags fire relative to page load, I thought it might be useful info.

@duracelltomi
Copy link
Owner

Thanks for sharing your findings, it is indeed valuable for others.
If you can share the URL of your site and let me know how I can place an order without using my credit card, I am happy to check it.

@Blueboots
Copy link

I spoke with the website owner and he has confirmed having the woocommerce_thankyou hook on the thankyou page.

I have done some test purchases, and although all the other ecommerce events work fine, the Purchase GTM event still doesn't fire.

If you can do a test yourself that would be great. The site is in Spanish. You can test purchase the following product and then choose the payment option of " transferencia bancaria" (bank transfer, so no payment card needed as you won't be doing the transfer).

https://lafargayherranz.com/comprar/percon-sk/

@Blueboots
Copy link

To clarify: I mean that the dataLayer event "purchase" is not produced even though the woocommerce_thankyou hook is present, so therefore my GA4 Ecommerce tag can't be triggered.

@duracelltomi
Copy link
Owner

Thanks for the clarification.
In that case, a payment gateway still breaks something.

Could you tell me what payment gateway you are using and whether they have some sort of sandbox environment where I could create an account install the plugin on my dev site? I did the same with Klarna earlier and was able to find solutions.

@Blueboots
Copy link

The payment gateways listed and activated within Woocommerce are:
redsys
cetelem
ppcp-gateway
bacs
bizum
sequra
bit2me

I don't think there will be any sandbox. It's a one man operation. Any clues would be most welcome.

@duracelltomi
Copy link
Owner

Could you pick one that does not work for you for sure?
I have the feeling that for example bacs should work but probably another non-standard payment don't.

@Blueboots
Copy link

Bacs is exactly the one I can test easily, and it doesn't work.

I presume none of the others do either, as my GA4 setup has not shown any purchases at all since the issue started.

@duracelltomi
Copy link
Owner

That is interesting, thanks!

@stefanpieter
Copy link

stefanpieter commented Apr 20, 2024

Same here.

The weird things is that in realtime view on GA4 the purchase gets captured, then a few hours later is gets removed.

I have been in contact with Google support and they advised the following:


We request you to kindly have the GTM setup on the back-end of the website directly. Please have the first code placed on the "head" section and the second code on the "Body" section on the back-end of the website.

Also ensure you take a back-up of the website before you install the codes along with this go to the plugin GTM4WP and please have the "container code" toggled off.

Kindly share the screenshot of the GTM plugin in the wordpress account as the Ecommerce data was sent using the plugin. So we requested you to kindly turn off the container code in the GTM plugin and install the Google Tag Manager script directly on the website.

If you have made this change today, I request you to kindly monitor the changes for the next 24-48 hours.

If the issue still persists, I request you to completely disable the plugin and set up the GA4 Ecommerce tracking using our developer guide which is a standard method of implementation.

Here is the link - https://developers.google.com/analytics/devguides/collection/ga4/ecommerce?client_type=gtm#make_a_purchase_or_issue_a_refund

You would require help from a developer and make changes to the script before installing them on the website. The document contains detailed instructions. Please follow the document and make changes accordingly.

@duracelltomi
Copy link
Owner

If the purhcase event appears in GA4 realtime but not in reports, that is an indication of a consent mode setup issue. It might happen that the analytics_storage flag is not (yet?) set to granted when the purchase event fires. I could be a race condition between the consent banner script and the purchase script.

Google's support just tries to eliminate some root case, for example a badly formatted GTM container code or a completely wrong ecommerce implementation. I would say neither is true with GTM4WP at least not in general.

@Blueboots
Copy link

move purchase tracking into another WooCommerce hook: woocommerce_thankyou

Hi,
could I ask if you have definite plans to advance this change?
My thank you page definitely has this hook so I hope it would solve the issue for me and hopefully for a few others as well.

@Blueboots
Copy link

Digging in more to try and at least find more clues to the root of my problem I see that the 'ecommerce' object is generated correctly on all pages EXCEPT the 'order-received' page. There, there is an 'orderData' object which I guess is what Woocommerce makes.

I've read you before saying that non-standard thank-you pages or plugins can break GTM4WP purchase tracking. I suppose they could also break the ecommerce object creation.
Could you give me any clues as to what I should be looking for while trying to fix this? Common plugins that cause problems? Any help much appreciated.

@Blueboots
Copy link

Hi everyone, feeling good as our bug was identified and fixed. Here are the details for all those interested.

The crypto coin plugin 'Bit2Me' was the cause that broke GTM4WP and stopped the creation of the ecommerce object and the purchase event on the ThankYou page. The website owner tells me that the plugin initially worked when we were on GTM4WP v1.19, but then broke on upgrading to v1.20 or v1.20.1 (That tracks with my memory of the course of events, but I was pretty confused at the time by implementing Consent Mode, which is what necessitated the upgrade to v1.20 in the first place. Phew!)

I can't give you any more technical details of why the Bit2Me plugin interfered with GTM4WP, sorry.
Hope this info is helpful to someone experiencing the same issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants