Add used dynamic filter types into tracking
[MAILPOET-4583]
This commit is contained in:
@@ -12,3 +12,51 @@ export function getTrackingData() {
|
||||
}
|
||||
return trackingDataLoading;
|
||||
}
|
||||
|
||||
export function mapFilterType(filter) {
|
||||
const action = filter.action;
|
||||
const filterType = filter.type;
|
||||
|
||||
if (filterType === 'email' && action === 'machineOpensAbsoluteCount')
|
||||
return '# of machine-opens';
|
||||
if (filterType === 'email' && action === 'opensAbsoluteCount')
|
||||
return '# of opens';
|
||||
if (filterType === 'woocommerce' && action === 'numberOfOrders')
|
||||
return '# of orders';
|
||||
if (filterType === 'email' && action === 'clicked') return 'clicked';
|
||||
if (filterType === 'email' && action === 'clickedAny')
|
||||
return 'clicked any email';
|
||||
if (filterType === 'userRole' && action === 'subscriberScore') return 'score';
|
||||
if (filterType === 'userRole' && action === 'subscribedToList')
|
||||
return 'subscribed to list';
|
||||
if (filterType === 'email' && action === 'opened') return 'opened';
|
||||
if (filterType === 'email' && action === 'machineOpened')
|
||||
return 'machine-opened';
|
||||
if (filterType === 'woocommerceMembership' && action === 'isMemberOf')
|
||||
return 'is active member of';
|
||||
if (
|
||||
filterType === 'woocommerceSubscription' &&
|
||||
action === 'hasActiveSubscription'
|
||||
)
|
||||
return 'has an active subscription';
|
||||
if (filterType === 'woocommerce' && action === 'customerInCountry')
|
||||
return 'is in country';
|
||||
if (filterType === 'userRole' && action === 'mailpoetCustomField')
|
||||
return 'MailPoet custom field';
|
||||
if (filterType === 'woocommerce' && action === 'purchasedCategory')
|
||||
return 'purchased in category';
|
||||
if (filterType === 'woocommerce' && action === 'purchasedProduct')
|
||||
return 'purchased product';
|
||||
if (filterType === 'userRole' && action === 'subscribedDate')
|
||||
return 'subscribed date';
|
||||
if (filterType === 'woocommerce' && action === 'totalSpent')
|
||||
return 'total spent';
|
||||
if (filterType === 'woocommerce' && action === 'totalSpent')
|
||||
return 'total spent';
|
||||
if (filterType === 'userRole' && action === 'wordpressRole')
|
||||
return 'WordPress user role';
|
||||
if (filterType === 'userRole' && action === 'subscriberTag')
|
||||
return 'subscriber tags';
|
||||
|
||||
return '';
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import _ from 'underscore';
|
||||
import _ from 'lodash';
|
||||
import { Component } from 'react';
|
||||
import jQuery from 'jquery';
|
||||
import PropTypes from 'prop-types';
|
||||
@@ -23,6 +23,7 @@ import { fromUrl } from 'common/thumbnail.ts';
|
||||
import { GlobalContext } from 'context/index.jsx';
|
||||
|
||||
import { extractEmailDomain } from 'common/functions';
|
||||
import { mapFilterType } from '../analytics';
|
||||
|
||||
const automaticEmails = window.mailpoet_woocommerce_automatic_emails || [];
|
||||
|
||||
@@ -352,12 +353,27 @@ class NewsletterSendComponent extends Component {
|
||||
}
|
||||
// redirect to listing based on newsletter type
|
||||
this.props.history.push(`/${this.state.item.type || ''}`);
|
||||
// prepare segments
|
||||
let filters = [];
|
||||
newsletter.data.segments.map((segment) =>
|
||||
filters.push(...segment.filters),
|
||||
);
|
||||
filters = _.uniqWith(
|
||||
filters,
|
||||
(filterA, filterB) =>
|
||||
filterA.action === filterB.action &&
|
||||
filterA.type === filterB.type,
|
||||
);
|
||||
const segments = filters
|
||||
.map((filter) => mapFilterType(filter))
|
||||
.join(', ');
|
||||
if (response.data.status === 'scheduled') {
|
||||
this.context.notices.success(
|
||||
<p>{MailPoet.I18n.t('newsletterHasBeenScheduled')}</p>,
|
||||
);
|
||||
MailPoet.trackEvent('Emails > Newsletter sent', {
|
||||
scheduled: true,
|
||||
segments,
|
||||
});
|
||||
} else {
|
||||
this.context.notices.success(
|
||||
@@ -366,6 +382,7 @@ class NewsletterSendComponent extends Component {
|
||||
);
|
||||
MailPoet.trackEvent('Emails > Newsletter sent', {
|
||||
scheduled: false,
|
||||
segments,
|
||||
});
|
||||
}
|
||||
MailPoet.Modal.loading(false);
|
||||
|
@@ -167,6 +167,7 @@ class Reporter {
|
||||
'Plugin > WooCommerce Multi-Currency' => $this->wp->isPluginActive('woocommerce-multi-currency/woocommerce-multi-currency.php'),
|
||||
'Plugin > Multi Currency for WooCommerce' => $this->wp->isPluginActive('woo-multi-currency/woo-multi-currency.php'),
|
||||
'Web host' => $this->settings->get('mta_group') == 'website' ? $this->settings->get('web_host') : null,
|
||||
// Dynamic segment filters tracking -- start. If you extend segments tracking, please extend mapping in analytics.js
|
||||
'Segment > # of machine-opens' => $this->isFilterTypeActive(DynamicSegmentFilterData::TYPE_EMAIL, EmailOpensAbsoluteCountAction::MACHINE_TYPE),
|
||||
'Segment > # of opens' => $this->isFilterTypeActive(DynamicSegmentFilterData::TYPE_EMAIL, EmailOpensAbsoluteCountAction::TYPE),
|
||||
'Segment > # of orders' => $this->isFilterTypeActive(DynamicSegmentFilterData::TYPE_WOOCOMMERCE, WooCommerceNumberOfOrders::ACTION_NUMBER_OF_ORDERS),
|
||||
@@ -186,6 +187,7 @@ class Reporter {
|
||||
'Segment > total spent' => $this->isFilterTypeActive(DynamicSegmentFilterData::TYPE_WOOCOMMERCE, WooCommerceTotalSpent::ACTION_TOTAL_SPENT),
|
||||
'Segment > WordPress user role' => $this->isFilterTypeActive(DynamicSegmentFilterData::TYPE_USER_ROLE, UserRole::TYPE),
|
||||
'Segment > subscriber tags' => $this->isFilterTypeActive(DynamicSegmentFilterData::TYPE_USER_ROLE, SubscriberTag::TYPE),
|
||||
// Dynamic segment filters tracking -- end. If you extend segments tracking, please extend mapping in analytics.js
|
||||
'Number of segments with multiple conditions' => $this->segmentsRepository->getSegmentCountWithMultipleFilters(),
|
||||
'Support tier' => $this->subscribersFeature->hasPremiumSupport() ? 'premium' : 'free',
|
||||
'Unauthorized email notice shown' => !empty($this->settings->get(AuthorizedEmailsController::AUTHORIZED_EMAIL_ADDRESSES_ERROR_SETTING)),
|
||||
|
Reference in New Issue
Block a user