Add GA event tracking for the Settings section
Feature Description
GA events should be added to keep track of interaction with the Settings section, exclusing those events which are shared with the dashboard Setup CTA Banner (see #9493).
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.
| Event Name | Category | Trigger | Condition | Description/details |
|---|---|---|---|---|
| enable_groups | {viewContext}_audiences-setup-cta-settings | Click | User clicks "Enable groups" | Setup and error events relating to the CTA are defined in #9493, see the "{viewContext}_audiences-setup" event category |
| view_notification | {viewContext}_audiences-setup-cta-settings-success | Element visibility | User views the Audience Segmentation Setup Success notification on the Settings screen | |
| confirm_notification | {viewContext}_audiences-setup-cta-settings-success | Click | User clicks "Show me" on the notification | |
| dismiss_notification | {viewContext}_audiences-setup-cta-settings-success | Click | User clicks "Got it" on the notification | |
| audience_widgets_enable | {viewContext}_audiences-settings | Click | User clicks the toggle to enable the audiences widget area | |
| audience_widgets_disable | {viewContext}_audiences-settings | Click | User clicks the toggle to disable the audiences widget area |
Implementation Brief
- [ ] In the
SettingsCardVisitorGroups/SetupCTAcomponent:- Create a
handleEnableGroups()callback:- Call
trackEvent( '${viewContext}_audiences-setup-cta-settings', 'enable_groups' ), followed byonEnableGroups(). Chain the two calls usingtrackEvent().finally().
- Call
- Replace
onEnableGroupswithhandleEnableGroupsas the value for theonClickprop that is passed toLink.
- Create a
- [ ] Refactor the
SettingsCardVisitorGroups/SetupSuccesscomponent to be a module with its own folder and anindex.jsfile. - [ ] Extract the rendered JSX content from the
SetupSuccesscomponent to a new component e.g.SetupSuccessContent.- Wrap the
SetupSuccessContentcomponent inforwardRef()so arefcan be passed to it, and add therefto its top-level rendered element.
- Wrap the
- [ ] In the
SettingsCardVisitorGroups/SetupSuccesscomponent:- Create a version of
SetupSuccessContentwrapped by thewithIntersectionObserver()HOC, e.g.SetupSuccessContentWithIntersectionObserver. Render this in place of the existingSetupSuccessContentinstance. - Pass the
onInViewcallback prop toSetupSuccessContentWithIntersectionObserver. In the callback, calltrackEvent( '${viewContext}_audiences-setup-cta-settings-success', 'view_notification' ).
- Create a version of
- [ ] In the
SetupSuccessContentcomponent:- Amend the
scrollToWidgetArea()callback:- Replace the call to
dismissNotificationForUser()with a direct call todismissItem()(alternatively, refactor the call todismissItem()to a reusable function). - Call
trackEvent( '${viewContext}_audiences-setup-cta-settings-success', 'confirm_notification' )prior to the calls todismissItem()andnavigateTo(). Chain the calls usingtrackEvent().finally().
- Replace the call to
- Amend the
dismissNotificationForUser()callback:- Call
trackEvent( '${viewContext}_audiences-setup-cta-settings-success', 'dismiss_notification' )prior to the call todismissItem(). Chain the two calls usingtrackEvent().finally().
- Call
- Amend the
- [ ] In the
SettingsCardVisitorGroupscomponent:- Amend the
handleKeyMetricsToggle()callback:- Determine the
actionfor the GA event:audience_widgets_enablewhenaudienceSegmentationWidgetHiddenis true, otherwiseaudience_widgets_disable. - Call
trackEvent( '${viewContext}_audiences-settings', action )prior to the calls tosetAudienceSegmentationWidgetHidden()andsaveAudienceSettings(). Chain the calls usingtrackEvent().finally().
- Determine the
- Amend the
Test Coverage
- Add JS test coverage for the above changes where tests exist for the affected components.
QA Brief
Changelog entry
Thank you for drafting the IB, @techanvil.
In the
SettingsCardVisitorGroups/SetupCTAcomponent:
- Create a version of
SetupSuccessContentwrapped by thewithIntersectionObserver()HOC, e.g.SetupSuccessContentWithIntersectionObserver. Render this in place of the existingSetupSuccessContentinstance.
Just to confirm, did you mean SettingsCardVisitorGroups/SetupSuccess (assets/js/modules/analytics-4/components/audience-segmentation/settings/SettingsCardVisitorGroups/SetupSuccess/index.js) instead of SettingsCardVisitorGroups/SetupCTA?
I certainly did, thanks for spotting another copy/pasta @nfmohit! I've updated the IB, cheers.
Brilliant, thanks Tom! IB ✅
QA Update ✅
Verified good. All events are being tracked as per the AC. Moving ticket to approval.
-
enable_groups
-
view_notification
-
confirm_notification
-
dismiss_notification
-
audience_widgets_enable
-
audience_widgets_disable