Open
Description
openedon Oct 11, 2024
Feature Description
GA events should be added to keep track of interaction with the Audience Selection Panel.
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 | Label | Trigger | Condition | Description/details |
---|---|---|---|---|---|
change_groups | {viewContext}_audiences-sidebar | Click | User clicks the "Change groups" CTA to open the Selection Panel | ||
audiences_sidebar_view | {viewContext}_audiences-sidebar | Element visibility | User views the Audiences Selection Panel | "Sidebar" events named for consistency with the corresponding event for KMW | |
audiences_sidebar_save | {viewContext}_audiences-sidebar | count of audiences by category in the format "user:123,site-kit:456,default:789" | Click | User clicks "Save selection" in the Selection Panel | |
audiences_sidebar_cancel | {viewContext}_audiences-sidebar | Click | User clicks "Cancel" in the Selection Panel | ||
insufficient_permissions_error | {viewContext}_audiences-sidebar | Element visibility | User views the insufficient permissions error when loading the Selection Panel data | ||
insufficient_permissions_error_request_access | {viewContext}_audiences-sidebar | Click | User clicks "Request access" on the error | ||
data_loading_error | {viewContext}_audiences-sidebar | Element visibility | User views the generic error when loading the Selection Panel data | ||
data_loading_error_retry | {viewContext}_audiences-sidebar | Click | User clicks "Retry" on the error | ||
view_notice | {viewContext}_audiences-sidebar-create-audiences | Element visibility | User views the Audience Creation Notice in the Selection Panel | ||
create_audience | {viewContext}_audiences-sidebar-create-audiences | one of "new-visitors", "returning-visitors" | Click | User clicks "Create" for one of the audiences in the notice | |
view_oauth_notice | {viewContext}_audiences-sidebar-create-audiences | Element visibility | User views the OAuth notice in the Audiences Creation Notice | ||
dismiss_oauth_notice | {viewContext}_audiences-sidebar-create-audiences | User clicks "Got it" on the OAuth notice | |||
view_notification | {viewContext}_audiences-sidebar-create-audiences-success | User views the success notification in the Audience Creation Notice | |||
dismiss_notification | {viewContext}_audiences-sidebar-create-audiences-success | User clicks "Got it" on the notification | |||
auth_error | {viewContext}_audiences-sidebar-create-audiences | Element visibility | User views the OAuth error notice in the Audience Creation Notice when an error occurs during audience creation | ||
insufficient_permissions_error | {viewContext}_audiences-sidebar-create-audiences | Element visibility | User views the insufficient permissions error notice in the Audience Creation Notice when an error occurs during audience creation | ||
insufficient_permissions_error_request_access | {viewContext}_audiences-sidebar-create-audiences | Click | User clicks "Request access" on the error notice | ||
setup_error | {viewContext}_audiences-sidebar-create-audiences | Element visibility | User views the generic error notice in the Audience Creation Notice when an error occurs during audience creation |
Implementation Brief
- In the
ChangeGroupsLink
component:- Call
trackEvent( '${viewContext}_audiences-sidebar', 'change_groups' )
in theopenAudiencesSelectionPanel()
callback.
- Call
- In the
AudienceSelectionPanel
component:- Call
trackEvent( '${viewContext}_audiences-sidebar', 'audiences_sidebar_view' )
in theonSideSheetOpen()
callback.
- Call
- In the
AudienceSelectionPanel/Footer
component:- Retrieve
availableAudiences
via thegetAvailableAudiences()
selector. - Add an
onSaveSuccess
callback prop to the renderedSelectionPanelFooter
:- Determine the
label
for the GA event in the formatuser:123,site-kit:456,default:789
by mappingconfiguredAudiences
to the number of audiences of the given type in the saved selection. The type can be determined by looking up theaudienceType
for an audience viaavailableAudiences
;123/456/789
are of course the number of audiences of the given type. - Call
trackEvent( '${viewContext}_audiences-sidebar', 'audiences_sidebar_save', label )
.
- Determine the
- Add an
onCancel
callback prop to the renderedSelectionPanelFooter
. In the callback, calltrackEvent( '${viewContext}_audiences-sidebar', 'audiences_sidebar_cancel' )
.
- Retrieve
- In the
AudienceSelectionPanel/ErrorNotice
component:- Retrieve the selection panel's open state via the
CORE_UI
AUDIENCE_SELECTION_PANEL_OPENED_KEY
value. - Create a variable,
hasErrors
which contains the value oferrors.length > 0
. This is to use in theuseEffect()
hook below to avoid passingerrors
as a dependency aserrors
will change more often. - Add a
useEffect()
hook.- Return early if the panel is closed or
hasErrors
is false. - If
hasInsufficientPermissionsError
is true, calltrackEvent( '${viewContext}_audiences-sidebar', 'insufficient_permissions_error' )
. - Otherwise, call
trackEvent( '${viewContext}_audiences-sidebar', 'data_loading_error' )
.
- Return early if the panel is closed or
- Retrieve the selection panel's open state via the
- In the
AudienceSelectionPanel/RequestAccessButton
component:- Add an
onClick
callback prop to the renderedButton
. In the callback, calltrackEvent( '${viewContext}_audiences-sidebar', 'insufficient_permissions_error_request_access' )
.
- Add an
- In the
AudienceSelectionPanel/RetryButton
component:- Add an
onClick
callback prop to the renderedButton
. In the callback, calltrackEvent( '${viewContext}_audiences-sidebar', 'data_loading_error_retry' )
.
- Add an
- In the
AudienceCreationNotice
component:- Retrieve the selection panel's open state via the
CORE_UI
AUDIENCE_SELECTION_PANEL_OPENED_KEY
value. - Add a
useEffect()
hook.- If the panel is open and
shouldShowNotice
is true, calltrackEvent( '${viewContext}_audiences-sidebar-create-audiences', 'view_notice' )
.
- If the panel is open and
- Amend the
onClick
handler for theSpinnerButton
component:- Determine the
label
for the event, which should benew-visitors
orreturning-visitors
depending on which audience is being created. - Call
trackEvent( '${viewContext}_audiences-sidebar-create-audiences', 'create_audience', label )
prior to the call tohandleCreateAudience
. Chain the two calls using.finally()
.
- Determine the
- Add another
useEffect()
hook.- Return early if the panel is closed.
- If the conditions for showing the
SubtleNotification
are true (i.e. if! hasAnalytics4EditScope && ! isEditScopeNoticeDismissed
) calltrackEvent( '${viewContext}_audiences-sidebar-create-audiences', 'view_oauth_notice' )
.
- Amend the
handleDismissEditScopeNotice()
callback:- Call
trackEvent( '${viewContext}_audiences-sidebar-create-audiences', 'dismiss_oauth_notice' )
prior to the call todismissItem
. Chain the two calls using.finally()
.
- Call
- Retrieve the selection panel's open state via the
- In the
AudienceCreationSuccessNotice
component:- Retrieve the selection panel's open state via the
CORE_UI
AUDIENCE_SELECTION_PANEL_OPENED_KEY
value. - Add a
useEffect()
hook.- If the panel is open and
showSuccessNotice
is true, calltrackEvent( '${viewContext}_audiences-sidebar-create-audiences-success', 'view_notification' )
.
- If the panel is open and
- Amend the
onClick
handler for theButton
component:- Call
trackEvent( '${viewContext}_audiences-sidebar-create-audiences-success', 'dismiss_notification' )
prior to the call tosetValue
. Chain the two calls using.finally()
.
- Call
- Retrieve the selection panel's open state via the
- In the
AudienceCreationErrorNotice
component:- Create a variable,
hasErrors
which contains the value oferrors.length > 0
. This is to use in theuseEffect()
hook below to avoid passingerrors
as a dependency aserrors
will change more often. - Add a
useEffect()
hook.- Return early if
hasErrors
is false. - If
hasOAuthError
is true, calltrackEvent( '${viewContext}_audiences-sidebar-create-audiences', 'auth_error' )
. - Otherwise, if
hasInsufficientPermissionsError
is true, calltrackEvent( '${viewContext}_audiences-sidebar-create-audiences', 'insufficient_permissions_error' )
. - Otherwise, call
trackEvent( '${viewContext}_audiences-sidebar-create-audiences', 'setup_error' )
.
- Return early if
- Add an
onClick
callback prop to the renderedButton
. In the callback, calltrackEvent( '${viewContext}_audiences-sidebar-create-audiences', 'insufficient_permissions_error_request_access' )
.
- Create a variable,
Test Coverage
- Add JS test coverage for the above changes where tests exist for the affected components.
QA Brief
Changelog entry
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment