-
Notifications
You must be signed in to change notification settings - Fork 339
Add GA event tracking for the Analytics setup CTA. #12031
Description
Feature Description
GA events should be added to keep track of interaction with the Analytics setup CTA (see #11816).
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
- The following GA events should be tracked for the given actions. See the GA events sheet.
- These changes are only active when the
setupFlowRefreshfeature flag is enabled.
| Event Name | Category | Label | Trigger | Condition |
|---|---|---|---|---|
| view_cta | {viewContext}_activate-analytics-cta | one of: search_funnel, wp_dashboard, admin_bar | element visibility | user views the Analytics setup CTA in the Search Funnel, WP Dashboard or Admin Bar |
| confirm_cta | {viewContext}_activate-analytics-cta | one of: search_funnel, wp_dashboard, admin_bar | click | user clicks the "Set up Analytics" button in the CTA |
| dismiss_cta | {viewContext}_activate-analytics-cta | one of: search_funnel, wp_dashboard, admin_bar | click | user clicks the "Maybe later" button to dismiss the CTA |
| click_learn_more_link | {viewContext}_activate-analytics-cta | one of: search_funnel, wp_dashboard, admin_bar | click | user clicks on the "Learn more" link in the CTA |
| _____________________ | ______________________________________ | _____________________________ | ______________ | __________________________________ |
Implementation Brief
-
In
assets/js/components/ActivateAnalyticsCTA.js:-
Accept a new prop,
analyticsEventLabel, which is a string. It will be passed to thetrackEventscallback functions (returned fromuseNotificationEvents) as alabelif it is notundefined. Pass the label to these functions using the following object structure:{ label: analyticsEventLabel; }
-
Use the
useNotificationEventshook, which returns atrackEventsobject used to track various events. The following parameters need to be passed touseNotificationEvents: -
id:activate-analytics-cta -
category:undefined -
An
actionsobject as follows:{ viewAction: 'view_cta', confirmAction: 'confirm_cta', dismissAction: 'dismiss_cta', clickLearnMoreAction: 'click_learn_more_link', }
-
Add the
useMounthook in the component to track the event when the component is first viewed. CalltrackEvents.viewto track theview_ctaaction according to the ACs. Pass the arguments to thetrackEvents.viewfunction as mentioned above. -
Create a new function,
handleDismiss, and calltrackEvents.dismisswithin it. ThedismissItemfunction should also be called afterward, as it is currently assigned to theonClickprop of the "Maybe later" button. Pass the arguments to thetrackEvents.dismissfunction as mentioned above. -
Add an
onClickprop to theLinkcomponent for the "Learn more" link (which is rendered when thesetupFlowRefreshfeature is enabled). This should accept a callback function that callstrackEvents.clickLearnMore. Pass the arguments to thetrackEvents.clickLearnMorefunction as mentioned above.
-
-
In
assets/js/components/adminbar/AdminBarActivateAnalyticsCTA.js:- Add the
analyticsEventLabelprop to theAnalyticsCTAcomponent and pass the valueadmin_barwhen thesetupFlowRefreshfeature is enabled.
- Add the
-
In
assets/js/components/wp-dashboard/WPDashboardActivateAnalyticsCTA.js:- Add the
analyticsEventLabelprop to theAnalyticsCTAcomponent and pass the valuewp_dashboardwhen thesetupFlowRefreshfeature is enabled.
- Add the
-
In
assets/js/modules/search-console/components/common/ActivateAnalyticsCTA.js:- Add the
analyticsEventLabelprop to theAnalyticsCTAcomponent and pass the valuesearch_funnelwhen thesetupFlowRefreshfeature is enabled.
- Add the
Test Coverage
- Update the tests for
AdminBarWidgets,SearchFunnelWidgetGA4, andWPDashboardWidgetsto verify the tracking events mentioned above.
Set up Site Kit with the setupFlowRefresh feature flag enabled. Don't connect Analytics.
Verify that the GA events are tracked according to AC for Analytics setup CTA which appears in following places.
- In searcg console widget on SK dashboard.
- Admin dashboard widgets in
Dashboardmenu of WordPress. - In admin bar on front end.
Changelog entry
- Add GA event tracking for user interaction with the Analytics setup CTA.