Skip to content

Commit 2719dfb

Browse files
authored
Plans on JP: Analytics (#20710)
* Show Free for First Year indication for domain suggestion cell for mapped domain type * Configure DomainSuggestionsViewController for free to paid plans flow - Handle .mapped domain case - Provide a callback when domain is added to cart * Create FreeToPaidPlansCoordinator to contain free to paid plans domains flow * Present domain suggestion from FreeToPaidPlansDashboardCard * Define a domain selection type to differentiate between different domain purchasing flows - Defined DomainSelectionType - Replaced usage of DomainType to DomainSelectionType to reflect 3 currently supported flows: registering domain with a domain credit, purchasing domain directly, and purchasing domain with a paid plan. * Track shown, hidden, and tap events of Free to Paid Plans Dashboard Card * Added Plan Selection Web View Viewed event * Add checkout web view viewed event * Track Plan Selection viewed event * Update PlansTracker.swift
1 parent 416615c commit 2719dfb

File tree

7 files changed

+113
-8
lines changed

7 files changed

+113
-8
lines changed

WordPress/Classes/Utility/Analytics/WPAnalyticsEvent.swift

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,18 @@ import Foundation
487487
case directDomainsPurchaseDashboardCardTapped
488488
case directDomainsPurchaseDashboardCardHidden
489489

490+
// Free to Paid Plans Dashboard Card
491+
case freeToPaidPlansDashboardCardShown
492+
case freeToPaidPlansDashboardCardTapped
493+
case freeToPaidPlansDashboardCardMenuTapped
494+
case freeToPaidPlansDashboardCardHidden
495+
496+
// Plan Selection
497+
case planSelectionWebViewViewed
498+
499+
// Checkout
500+
case checkoutWebViewViewed
501+
490502
/// A String that represents the event
491503
var value: String {
492504
switch self {
@@ -1326,6 +1338,24 @@ import Foundation
13261338
case .directDomainsPurchaseDashboardCardTapped:
13271339
return "direct_domains_purchase_dashboard_card_tapped"
13281340

1341+
// Free to Paid Plans Dashboard Card
1342+
case .freeToPaidPlansDashboardCardShown:
1343+
return "free_to_paid_plan_dashboard_card_shown"
1344+
case .freeToPaidPlansDashboardCardHidden:
1345+
return "free_to_paid_plan_dashboard_card_hidden"
1346+
case .freeToPaidPlansDashboardCardTapped:
1347+
return "free_to_paid_plan_dashboard_card_tapped"
1348+
case .freeToPaidPlansDashboardCardMenuTapped:
1349+
return "free_to_paid_plan_dashboard_card_menu_tapped"
1350+
1351+
// Plan Selection
1352+
case .planSelectionWebViewViewed:
1353+
return "plan_selection_webview_viewed"
1354+
1355+
// Checkout
1356+
case .checkoutWebViewViewed:
1357+
return "checkout_webview_viewed"
1358+
13291359
} // END OF SWITCH
13301360
}
13311361

WordPress/Classes/ViewRelated/Blog/Blog Dashboard/Cards/Domains/BaseDashboardDomainsCardCell.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ class BaseDashboardDomainsCardCell: DashboardCollectionViewCell {
9494
self.blog = blog
9595
self.presentingViewController = viewController
9696

97-
DomainsDashboardCardTracker.trackDirectDomainsPurchaseDashboardCardShown(in: row)
97+
viewModel.onViewShow()
9898
}
9999
}
100100

@@ -140,15 +140,18 @@ struct DashboardDomainsCardViewModel {
140140
}
141141

142142
let strings: DashboardDomainsCardViewModel.Strings
143+
let onViewShow: () -> Void
143144
let onViewTap: () -> Void
144145
let onEllipsisTap: () -> Void
145146
let onHideThisTap: UIActionHandler
146147

147148
init(strings: DashboardDomainsCardViewModel.Strings,
149+
onViewShow: @escaping () -> Void = {},
148150
onViewTap: @escaping () -> Void = {},
149151
onEllipsisTap: @escaping () -> Void = {},
150152
onHideThisTap: @escaping UIActionHandler = { _ in }) {
151153
self.strings = strings
154+
self.onViewShow = onViewShow
152155
self.onViewTap = onViewTap
153156
self.onEllipsisTap = onEllipsisTap
154157
self.onHideThisTap = onHideThisTap

WordPress/Classes/ViewRelated/Blog/Blog Dashboard/Cards/Domains/DashboardDomainsCardCell.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ final class DashboardDomainsCardCell: BaseDashboardDomainsCardCell {
66
}
77

88
private lazy var cardViewModel: DashboardDomainsCardViewModel = {
9+
let onViewShow: () -> Void = { [weak self] in
10+
guard let self = self else {
11+
return
12+
}
13+
14+
DomainsDashboardCardTracker.trackDirectDomainsPurchaseDashboardCardShown(in: self.row)
15+
}
16+
917
let onViewTap: () -> Void = { [weak self] in
1018
guard let self,
1119
let presentingViewController = self.presentingViewController,
@@ -37,6 +45,7 @@ final class DashboardDomainsCardCell: BaseDashboardDomainsCardCell {
3745
hideThis: Strings.hideThis,
3846
source: Strings.source
3947
),
48+
onViewShow: onViewShow,
4049
onViewTap: onViewTap,
4150
onEllipsisTap: onEllipsisTap,
4251
onHideThisTap: onHideThisTap

WordPress/Classes/ViewRelated/Blog/Blog Dashboard/Cards/Free to Paid Plans/FreeToPaidPlansCoordinator.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ import UIKit
1616
guard let viewModel = PlanSelectionViewModel(blog: blog) else { return }
1717
let planSelectionViewController = PlanSelectionViewController(viewModel: viewModel)
1818
domainSuggestionsViewController.show(planSelectionViewController, sender: nil)
19+
20+
PlansTracker.trackPlanSelectionWebViewViewed(.domainAndPlanPackage, source: "domains_register")
1921
}
2022

2123
dashboardViewController.show(domainSuggestionsViewController, sender: nil)

WordPress/Classes/ViewRelated/Blog/Blog Dashboard/Cards/Free to Paid Plans/FreeToPaidPlansDashboardCardCell.swift

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ final class FreeToPaidPlansDashboardCardCell: BaseDashboardDomainsCardCell {
66
}
77

88
private lazy var cardViewModel: DashboardDomainsCardViewModel = {
9+
let onViewShow: () -> Void = { [weak self] in
10+
guard let self = self else {
11+
return
12+
}
13+
14+
PlansTracker.trackFreeToPaidPlansDashboardCardShown(in: self.row)
15+
}
16+
917
let onViewTap: () -> Void = { [weak self] in
1018
guard let self,
1119
let presentingViewController = self.presentingViewController,
@@ -19,22 +27,22 @@ final class FreeToPaidPlansDashboardCardCell: BaseDashboardDomainsCardCell {
1927
blog: blog
2028
)
2129

22-
// TODO: Analytics
23-
// https://github.com/wordpress-mobile/WordPress-iOS/issues/20692
30+
PlansTracker.trackFreeToPaidPlansDashboardCardTapped(in: self.row)
2431
}
2532

2633
let onEllipsisTap: () -> Void = { [weak self] in
27-
// TODO: Analytics
28-
// https://github.com/wordpress-mobile/WordPress-iOS/issues/20692
34+
guard let self else {
35+
return
36+
}
37+
38+
PlansTracker.trackFreeToPaidPlansDashboardCardMenuTapped(in: self.row)
2939
}
3040

3141
let onHideThisTap: UIActionHandler = { [weak self] _ in
3242
guard let self else { return }
3343

3444
FreeToPaidPlansDashboardCardHelper.hideCard(for: self.blog)
35-
36-
// TODO: Analytics
37-
// https://github.com/wordpress-mobile/WordPress-iOS/issues/20692
45+
PlansTracker.trackFreeToPaidPlansDashboardCardHidden(in: self.row)
3846

3947
self.presentingViewController?.reloadCardsLocally()
4048
}
@@ -46,6 +54,7 @@ final class FreeToPaidPlansDashboardCardCell: BaseDashboardDomainsCardCell {
4654
hideThis: Strings.hideThis,
4755
source: Strings.source
4856
),
57+
onViewShow: onViewShow,
4958
onViewTap: onViewTap,
5059
onEllipsisTap: onEllipsisTap,
5160
onHideThisTap: onHideThisTap
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import Foundation
2+
3+
struct PlansTracker {
4+
enum PlanSelectionType: String {
5+
case domainAndPlanPackage = "domain_and_plan_package"
6+
}
7+
8+
private static let positionKey = "position_index"
9+
private static let planSelectionTypeKey = "plan_selection_type"
10+
11+
// MARK: - Dashboard Card
12+
13+
static func trackFreeToPaidPlansDashboardCardShown(in position: Int) {
14+
let properties = [positionKey: position]
15+
WPAnalytics.track(.freeToPaidPlansDashboardCardShown, properties: properties)
16+
}
17+
18+
static func trackFreeToPaidPlansDashboardCardHidden(in position: Int) {
19+
let properties = [positionKey: position]
20+
WPAnalytics.track(.freeToPaidPlansDashboardCardHidden, properties: properties)
21+
}
22+
23+
static func trackFreeToPaidPlansDashboardCardTapped(in position: Int) {
24+
let properties = [positionKey: position]
25+
WPAnalytics.track(.freeToPaidPlansDashboardCardTapped, properties: properties)
26+
}
27+
28+
static func trackFreeToPaidPlansDashboardCardMenuTapped(in position: Int) {
29+
let properties = [positionKey: position]
30+
WPAnalytics.track(.freeToPaidPlansDashboardCardMenuTapped, properties: properties)
31+
}
32+
33+
// MARK: - Plan Selection
34+
35+
static func trackPlanSelectionWebViewViewed(_ type: PlanSelectionType, source: String) {
36+
let properties = ["source": source, planSelectionTypeKey: type.rawValue]
37+
WPAnalytics.track(.planSelectionWebViewViewed, properties: properties)
38+
}
39+
40+
// MARK: - Checkout
41+
42+
static func trackCheckoutWebViewViewed(source: String) {
43+
let properties = ["source": source]
44+
WPAnalytics.track(.checkoutWebViewViewed, properties: properties)
45+
}
46+
}

WordPress/WordPress.xcodeproj/project.pbxproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,8 @@
156156
011F52C62A15413800B04114 /* FreeToPaidPlansDashboardCardHelperTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 011F52C52A15413800B04114 /* FreeToPaidPlansDashboardCardHelperTests.swift */; };
157157
011F52C82A16551A00B04114 /* FreeToPaidPlansCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 011F52C72A16551A00B04114 /* FreeToPaidPlansCoordinator.swift */; };
158158
011F52C92A16551A00B04114 /* FreeToPaidPlansCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 011F52C72A16551A00B04114 /* FreeToPaidPlansCoordinator.swift */; };
159+
011F52D32A1B84FF00B04114 /* PlansTracker.swift in Sources */ = {isa = PBXBuildFile; fileRef = 011F52D22A1B84FF00B04114 /* PlansTracker.swift */; };
160+
011F52D42A1B84FF00B04114 /* PlansTracker.swift in Sources */ = {isa = PBXBuildFile; fileRef = 011F52D22A1B84FF00B04114 /* PlansTracker.swift */; };
159161
01281E9A2A0456CB00464F8F /* DomainsSuggestionsScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01281E992A0456CB00464F8F /* DomainsSuggestionsScreen.swift */; };
160162
01281E9C2A051EEA00464F8F /* MenuNavigationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01281E9B2A051EEA00464F8F /* MenuNavigationTests.swift */; };
161163
01281E9D2A051EEA00464F8F /* MenuNavigationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01281E9B2A051EEA00464F8F /* MenuNavigationTests.swift */; };
@@ -5795,6 +5797,7 @@
57955797
011F52C22A153A3400B04114 /* FreeToPaidPlansDashboardCardHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FreeToPaidPlansDashboardCardHelper.swift; sourceTree = "<group>"; };
57965798
011F52C52A15413800B04114 /* FreeToPaidPlansDashboardCardHelperTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FreeToPaidPlansDashboardCardHelperTests.swift; sourceTree = "<group>"; };
57975799
011F52C72A16551A00B04114 /* FreeToPaidPlansCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FreeToPaidPlansCoordinator.swift; sourceTree = "<group>"; };
5800+
011F52D22A1B84FF00B04114 /* PlansTracker.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PlansTracker.swift; sourceTree = "<group>"; };
57985801
01281E992A0456CB00464F8F /* DomainsSuggestionsScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DomainsSuggestionsScreen.swift; sourceTree = "<group>"; };
57995802
01281E9B2A051EEA00464F8F /* MenuNavigationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MenuNavigationTests.swift; sourceTree = "<group>"; };
58005803
0141929B2983F0A300CAEDB0 /* SupportConfiguration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SupportConfiguration.swift; sourceTree = "<group>"; };
@@ -9684,6 +9687,7 @@
96849687
011F52BB2A15324800B04114 /* Free to Paid Plans */ = {
96859688
isa = PBXGroup;
96869689
children = (
9690+
011F52D22A1B84FF00B04114 /* PlansTracker.swift */,
96879691
011F52BF2A1538EC00B04114 /* FreeToPaidPlansDashboardCardCell.swift */,
96889692
011F52C22A153A3400B04114 /* FreeToPaidPlansDashboardCardHelper.swift */,
96899693
011F52C72A16551A00B04114 /* FreeToPaidPlansCoordinator.swift */,
@@ -21060,6 +21064,7 @@
2106021064
40F50B7E22130E6C00CBBB73 /* FollowersStatsRecordValue+CoreDataProperties.swift in Sources */,
2106121065
FAD95D2725B91BCF00F011B5 /* JetpackRestoreStatusFailedViewController.swift in Sources */,
2106221066
E66969DC1B9E55C300EC9C00 /* ReaderTopicToReaderListTopic37to38.swift in Sources */,
21067+
011F52D32A1B84FF00B04114 /* PlansTracker.swift in Sources */,
2106321068
9A2D0B23225CB92B009E585F /* BlogService+JetpackConvenience.swift in Sources */,
2106421069
C856748F243EF177001A995E /* GutenbergTenorMediaPicker.swift in Sources */,
2106521070
83C972E0281C45AB0049E1FE /* Post+BloggingPrompts.swift in Sources */,
@@ -25008,6 +25013,7 @@
2500825013
FEA7949126DF7F3700CEC520 /* WPStyleGuide+CommentDetail.swift in Sources */,
2500925014
011896A029D30CAD00D34BA9 /* DomainsDashboardCardTracker.swift in Sources */,
2501025015
FABB24C82602FC2C00C8785C /* StockPhotosPicker.swift in Sources */,
25016+
011F52D42A1B84FF00B04114 /* PlansTracker.swift in Sources */,
2501125017
FABB24CA2602FC2C00C8785C /* UnifiedPrologueViewController.swift in Sources */,
2501225018
FABB24CC2602FC2C00C8785C /* CollapsableHeaderViewController.swift in Sources */,
2501325019
FABB24CD2602FC2C00C8785C /* Blog+Lookup.swift in Sources */,

0 commit comments

Comments
 (0)