The problem is that your order-received page (/finalizar-compra/order-pay/) is not registered as the order-received page in WooCommerce.
You must make sure that order-pay is registered as the order-received page in the Woo settings under: WooCommerce > Advanced > Page.
This may not be enough if the problem was caused by customization or a payment plugin that does not comply with the Woo standard.
You need to make sure that your order received page works with the WooCommerce function is_order_received_page()
. If you want a customized order received page, best practise is to modify the wocommerce/checkout/thankyou.php
template in you theme.
GTM Kit fires the events as follows:
The begin_checkout event is fired if the WooCommerce function is_checkout() === true
The purchase event is fired if the WooCommerce function is_order_received_page() === true
The reason why you have a begin_checkout event on your order-received page is because the is_order_received_page()
check failed, and is_checkout()
is true for both /checkout/order-received
and /checkout
. That is why the is_order_received_page()
is checked first in WooCommerce.php#L327
So, if your order received page is recognized by WooCommerce as such it will work as expected.
If you have a customized order-received page that for some reason is not recognized by the is_order_received_page()
function you can use the filter hook woocommerce_is_order_received_page
and set the value to true on your order received page.
In any case this is a WooCommerce issue and not a problem that can be solved in GTM Kit or Google Tag Manager because GTM Kit relies on is_order_received_page()
.