diff --git a/plugins/woocommerce/includes/admin/helper/class-wc-helper.php b/plugins/woocommerce/includes/admin/helper/class-wc-helper.php index ae9afbf0a6f..6ea8016ccb9 100644 --- a/plugins/woocommerce/includes/admin/helper/class-wc-helper.php +++ b/plugins/woocommerce/includes/admin/helper/class-wc-helper.php @@ -223,7 +223,10 @@ class WC_Helper { $action['message'] .= ' ' . __( 'To enable this update you need to purchase a new subscription.', 'woocommerce' ); $action['button_label'] = __( 'Purchase', 'woocommerce' ); - $action['button_url'] = $subscription['product_url']; + $action['button_url'] = self::add_utm_params_to_url_for_subscription_link( + $subscription['product_url'], + 'purchase' + ); $subscription['actions'][] = $action; } elseif ( $subscription['expired'] && ! empty( $subscription['master_user_email'] ) ) { @@ -238,7 +241,10 @@ class WC_Helper { $action = array( 'message' => sprintf( __( 'This subscription has expired. Please renew to receive updates and support.', 'woocommerce' ) ), 'button_label' => __( 'Renew', 'woocommerce' ), - 'button_url' => 'https://woocommerce.com/my-account/my-subscriptions/', + 'button_url' => self::add_utm_params_to_url_for_subscription_link( + 'https://woocommerce.com/my-account/my-subscriptions/', + 'renew' + ), 'status' => 'expired', 'icon' => 'dashicons-info', ); @@ -250,7 +256,10 @@ class WC_Helper { $action = array( 'message' => __( 'Subscription is expiring soon.', 'woocommerce' ), 'button_label' => __( 'Enable auto-renew', 'woocommerce' ), - 'button_url' => 'https://woocommerce.com/my-account/my-subscriptions/', + 'button_url' => self::add_utm_params_to_url_for_subscription_link( + 'https://woocommerce.com/my-account/my-subscriptions/', + 'auto-renew' + ), 'status' => 'expired', 'icon' => 'dashicons-info', ); @@ -261,7 +270,10 @@ class WC_Helper { $action = array( 'message' => sprintf( __( 'This subscription is expiring soon. Please renew to continue receiving updates and support.', 'woocommerce' ) ), 'button_label' => __( 'Renew', 'woocommerce' ), - 'button_url' => 'https://woocommerce.com/my-account/my-subscriptions/', + 'button_url' => self::add_utm_params_to_url_for_subscription_link( + 'https://woocommerce.com/my-account/my-subscriptions/', + 'renew' + ), 'status' => 'expired', 'icon' => 'dashicons-info', ); @@ -309,7 +321,10 @@ class WC_Helper { /* translators: %s: version number */ 'message' => sprintf( __( 'Version %s is available. To enable this update you need to purchase a new subscription.', 'woocommerce' ), esc_html( $updates[ $data['_product_id'] ]['version'] ) ), 'button_label' => __( 'Purchase', 'woocommerce' ), - 'button_url' => $data['_product_url'], + 'button_url' => self::add_utm_params_to_url_for_subscription_link( + $data['_product_url'], + 'purchase' + ), 'status' => 'expired', 'icon' => 'dashicons-info', ); @@ -320,7 +335,10 @@ class WC_Helper { /* translators: 1: subscriptions docs 2: subscriptions docs */ 'message' => sprintf( __( 'To receive updates and support for this extension, you need to purchase a new subscription or consolidate your extensions to one connected account by sharing or transferring this extension to this connected account.', 'woocommerce' ), 'https://docs.woocommerce.com/document/managing-woocommerce-com-subscriptions/#section-10', 'https://docs.woocommerce.com/document/managing-woocommerce-com-subscriptions/#section-5' ), 'button_label' => __( 'Purchase', 'woocommerce' ), - 'button_url' => $data['_product_url'], + 'button_url' => self::add_utm_params_to_url_for_subscription_link( + $data['_product_url'], + 'purchase' + ), 'status' => 'expired', 'icon' => 'dashicons-info', ); @@ -350,6 +368,28 @@ class WC_Helper { return; } + /** + * Add tracking parameters to buttons (Renew, Purchase, etc.) on subscriptions page + * + * @param string $url URL to product page or to https://woocommerce.com/my-account/my-subscriptions/ + * @param string $utm_content value of utm_content query parameter used for tracking + * + * @return string URL including utm parameters for tracking + */ + public static function add_utm_params_to_url_for_subscription_link( $url, $utm_content ) { + $utm_params = 'utm_source=subscriptionsscreen&' . + 'utm_medium=product&' . + 'utm_campaign=wcaddons&' . + 'utm_content=' . $utm_content; + + // there are already some URL parameters + if ( strpos( $url, '?' ) ) { + return $url . '&' . $utm_params; + } + + return $url . '?' . $utm_params; + } + /** * Get available subscriptions filters. * diff --git a/plugins/woocommerce/includes/admin/helper/views/html-main.php b/plugins/woocommerce/includes/admin/helper/views/html-main.php index 7aa6a8fba41..7578721fade 100644 --- a/plugins/woocommerce/includes/admin/helper/views/html-main.php +++ b/plugins/woocommerce/includes/admin/helper/views/html-main.php @@ -75,7 +75,7 @@