diff --git a/changelog/add-pay-for-order-tracks b/changelog/add-pay-for-order-tracks new file mode 100644 index 00000000000..a1e84990229 --- /dev/null +++ b/changelog/add-pay-for-order-tracks @@ -0,0 +1,4 @@ +Significance: minor +Type: dev + +Add pay-for-order Tracks events diff --git a/includes/class-wc-payments-woopay-button-handler.php b/includes/class-wc-payments-woopay-button-handler.php index ab637e1040c..37529dc030e 100644 --- a/includes/class-wc-payments-woopay-button-handler.php +++ b/includes/class-wc-payments-woopay-button-handler.php @@ -454,14 +454,14 @@ public function get_button_context() { return 'cart'; } - if ( $this->is_checkout() ) { - return 'checkout'; - } - if ( $this->is_pay_for_order_page() ) { return 'pay_for_order'; } + if ( $this->is_checkout() ) { + return 'checkout'; + } + return ''; } diff --git a/includes/class-woopay-tracker.php b/includes/class-woopay-tracker.php index 2006fb19906..564fd0c5033 100644 --- a/includes/class-woopay-tracker.php +++ b/includes/class-woopay-tracker.php @@ -70,6 +70,7 @@ public function __construct( $http ) { add_action( 'woocommerce_checkout_order_processed', [ $this, 'checkout_order_processed' ] ); add_action( 'woocommerce_blocks_checkout_order_processed', [ $this, 'checkout_order_processed' ] ); add_action( 'woocommerce_payments_save_user_in_woopay', [ $this, 'must_save_payment_method_to_platform' ] ); + add_action( 'before_woocommerce_pay_form', [ $this, 'pay_for_order_page_view' ] ); } /** @@ -423,6 +424,15 @@ public function classic_product_page_view() { ); } + /** + * Record a Tracks event that the pay-for-order page has loaded. + */ + public function pay_for_order_page_view() { + $this->maybe_record_wcpay_shopper_event( + 'pay_for_order_page_view' + ); + } + /** * Record a Tracks event that the order has been processed. */