Add tracking for users arriving to the wizard from WooCommerce Marketing Dashboard
Users can click on the Finish setup button on the WooCommerce Multichannel Marketing Dashboard which would redirect them to the MailPoet welcome wizard. We want to track users that arrive to the MP wizard from WooCommerce but at this point tracking is not enabled. So we store the information in a setting, and send the tracking event to Mixpanel, if it is enabled, after the user completes the wizard. MAILPOET-5695
This commit is contained in:
committed by
Aschepikov
parent
b7f53b5f4a
commit
2a714511c2
1
mailpoet/assets/js/src/global.d.ts
vendored
1
mailpoet/assets/js/src/global.d.ts
vendored
@@ -108,6 +108,7 @@ interface Window {
|
||||
mailpoet_woocommerce_store_config: WooCommerceStoreConfig;
|
||||
mailpoet_woocommerce_version: string;
|
||||
mailpoet_track_wizard_loaded_via_woocommerce: boolean;
|
||||
mailpoet_track_wizard_loaded_via_woocommerce_marketing_dashboard: boolean;
|
||||
mailpoet_premium_active: boolean;
|
||||
mailpoet_subscribers_limit: number;
|
||||
mailpoet_subscribers_limit_reached: boolean;
|
||||
|
@@ -15,6 +15,21 @@ function trackWizardLoadedViaWooCommerce() {
|
||||
data: 'send_event_that_wizard_was_loaded_via_woocommerce',
|
||||
});
|
||||
}
|
||||
|
||||
if (window.mailpoet_track_wizard_loaded_via_woocommerce_marketing_dashboard) {
|
||||
window.MailPoet.trackEvent(
|
||||
'User clicked on complete MailPoet setup in WooCommerce > Multichannel Marketing dashboard',
|
||||
{
|
||||
'WooCommerce version': window.mailpoet_woocommerce_version,
|
||||
},
|
||||
);
|
||||
void window.MailPoet.Ajax.post({
|
||||
api_version: window.mailpoet_api_version,
|
||||
endpoint: 'settings',
|
||||
action: 'delete',
|
||||
data: 'wizard_loaded_via_woocommerce_marketing_dashboard',
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', trackWizardLoadedViaWooCommerce);
|
||||
|
@@ -165,6 +165,7 @@ class PageRenderer {
|
||||
'send_transactional_emails' => (bool)$this->settings->get('send_transactional_emails'),
|
||||
'transactional_emails_opt_in_notice_dismissed' => (bool)$this->userFlags->get('transactional_emails_opt_in_notice_dismissed'),
|
||||
'track_wizard_loaded_via_woocommerce' => (bool)$this->settings->get(WelcomeWizard::TRACK_LOADDED_VIA_WOOCOMMERCE_SETTING_NAME),
|
||||
'track_wizard_loaded_via_woocommerce_marketing_dashboard' => (bool)$this->settings->get(WelcomeWizard::TRACK_LOADDED_VIA_WOOCOMMERCE_MARKETING_DASHBOARD_SETTING_NAME),
|
||||
'mail_function_enabled' => function_exists('mail') && is_callable('mail'),
|
||||
'admin_plugins_url' => WPFunctions::get()->adminUrl('plugins.php'),
|
||||
|
||||
|
@@ -11,6 +11,7 @@ use MailPoet\WP\Functions as WPFunctions;
|
||||
|
||||
class WelcomeWizard {
|
||||
const TRACK_LOADDED_VIA_WOOCOMMERCE_SETTING_NAME = 'send_event_that_wizard_was_loaded_via_woocommerce';
|
||||
const TRACK_LOADDED_VIA_WOOCOMMERCE_MARKETING_DASHBOARD_SETTING_NAME = 'wizard_loaded_via_woocommerce_marketing_dashboard';
|
||||
|
||||
/** @var PageRenderer */
|
||||
private $pageRenderer;
|
||||
@@ -51,6 +52,13 @@ class WelcomeWizard {
|
||||
$this->settings->set(WelcomeWizard::TRACK_LOADDED_VIA_WOOCOMMERCE_SETTING_NAME, 1);
|
||||
}
|
||||
|
||||
$loadedViaWooCommerceMarketingDashboard = $this->settings->get(WelcomeWizard::TRACK_LOADDED_VIA_WOOCOMMERCE_MARKETING_DASHBOARD_SETTING_NAME, false);
|
||||
|
||||
if (!$loadedViaWooCommerceMarketingDashboard && isset($_GET['mailpoet_wizard_loaded_via_woocommerce_marketing_dashboard'])) {
|
||||
// This setting is used to send an event to Mixpanel in another request as, before completing the wizard, Mixpanel is not enabled.
|
||||
$this->settings->set(WelcomeWizard::TRACK_LOADDED_VIA_WOOCOMMERCE_MARKETING_DASHBOARD_SETTING_NAME, 1);
|
||||
}
|
||||
|
||||
|
||||
$premiumKeyValid = $this->servicesChecker->isPremiumKeyValid(false);
|
||||
// force MSS key check even if the method isn't active
|
||||
|
@@ -66,6 +66,7 @@
|
||||
var mailpoet_deactivate_subscriber_after_inactive_days = <%= json_encode(deactivate_subscriber_after_inactive_days) %>;
|
||||
var mailpoet_woocommerce_version = <%= json_encode(get_woocommerce_version()) %>;
|
||||
var mailpoet_track_wizard_loaded_via_woocommerce = <%= json_encode(track_wizard_loaded_via_woocommerce) %>;
|
||||
var mailpoet_track_wizard_loaded_via_woocommerce_marketing_dashboard = <%= json_encode(track_wizard_loaded_via_woocommerce_marketing_dashboard) %>;
|
||||
var mailpoet_mail_function_enabled = '<%= mail_function_enabled %>';
|
||||
var mailpoet_admin_plugins_url = '<%= admin_plugins_url %>';
|
||||
var mailpoet_is_dotcom = <%= json_encode(is_dotcom()) %>;
|
||||
|
Reference in New Issue
Block a user