From ef131029a58aacc34bc56ba554ed57468eb61597 Mon Sep 17 00:00:00 2001 From: Joshua Flowers Date: Wed, 13 May 2020 17:44:26 +0300 Subject: [PATCH] Add function to enable tracking client-side --- includes/tracks/class-wc-site-tracking.php | 52 +++++++++++++++++++--- 1 file changed, 45 insertions(+), 7 deletions(-) diff --git a/includes/tracks/class-wc-site-tracking.php b/includes/tracks/class-wc-site-tracking.php index 84c45a62aad..7699e43794c 100644 --- a/includes/tracks/class-wc-site-tracking.php +++ b/includes/tracks/class-wc-site-tracking.php @@ -44,17 +44,18 @@ class WC_Site_Tracking { return true; } + /** + * Register scripts required to record events from javascript. + */ + public static function register_scripts() { + wp_register_script( 'woo-tracks', 'https://stats.wp.com/w.js', array( 'wp-hooks' ), gmdate( 'YW' ), false ); + } + /** * Add scripts required to record events from javascript. */ public static function enqueue_scripts() { - - // Add w.js to the page. - wp_enqueue_script( 'woo-tracks', 'https://stats.wp.com/w.js', array( 'wp-hooks' ), gmdate( 'YW' ), false ); - - // Expose tracking via a function in the wcTracks global namespace directly before wc_print_js. - add_filter( 'admin_footer', array( __CLASS__, 'add_tracking_function' ), 24 ); - + wp_enqueue_script( 'woo-tracks' ); } /** @@ -87,15 +88,52 @@ class WC_Site_Tracking { registered['woo-tracks']->src; + + ?> + +