Add tracking for theme activation so that we can track active block themes in WooCommerce
This commit is contained in:
parent
e767d9f220
commit
1c01cc1605
|
@ -161,6 +161,7 @@ class WC_Site_Tracking {
|
|||
include_once WC_ABSPATH . 'includes/tracks/events/class-wc-coupons-tracking.php';
|
||||
include_once WC_ABSPATH . 'includes/tracks/events/class-wc-order-tracking.php';
|
||||
include_once WC_ABSPATH . 'includes/tracks/events/class-wc-coupon-tracking.php';
|
||||
include_once WC_ABSPATH . 'includes/tracks/events/class-wc-theme-tracking.php';
|
||||
|
||||
$tracking_classes = array(
|
||||
'WC_Extensions_Tracking',
|
||||
|
@ -172,6 +173,7 @@ class WC_Site_Tracking {
|
|||
'WC_Coupons_Tracking',
|
||||
'WC_Order_Tracking',
|
||||
'WC_Coupon_Tracking',
|
||||
'WC_Theme_Tracking',
|
||||
);
|
||||
|
||||
foreach ( $tracking_classes as $tracking_class ) {
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
/**
|
||||
* WooCommerce Theme Tracking
|
||||
*
|
||||
* @package WooCommerce\Tracks
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* This class adds actions to track usage of a WooCommerce Order.
|
||||
*/
|
||||
class WC_Theme_Tracking {
|
||||
|
||||
/**
|
||||
* Init tracking.
|
||||
*/
|
||||
public function init() {
|
||||
add_action( 'switch_theme', array( $this, 'track_theme_activated' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a Tracks event when a theme is activated so that we can track active block themes.
|
||||
*/
|
||||
public function track_theme_activated() {
|
||||
if ( ! function_exists( 'wc_current_theme_is_fse_theme' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$properties = array(
|
||||
'block_theme' => wc_current_theme_is_fse_theme(),
|
||||
);
|
||||
|
||||
WC_Tracks::record_event( 'theme_activated', $properties );
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue