WC_Helper::add_utm_params_to_url_for_subscription_link()public staticWC 1.0

Add tracking parameters to buttons (Renew, Purchase, etc.) on subscriptions page

Method of the class: WC_Helper{}

No Hooks.

Return

String. URL including utm parameters for tracking

Usage

$result = WC_Helper::add_utm_params_to_url_for_subscription_link( $url, $utm_content );
$url(string) (required)
URL to product page or to https://woocommerce.com/my-account/my-subscriptions/.
$utm_content(string) (required)
value of utm_content query parameter used for tracking

WC_Helper::add_utm_params_to_url_for_subscription_link() code WC 9.3.3

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;
}