Add GA event tracking for the Audiences Tiles (excluding the "Top content" metric area)
Feature Description
GA events should be added to keep track of interaction with Audience Tiles (barring the "Top content" metric area which will be addressed separately).
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 |
|---|---|---|---|---|
| insufficient_permissions_error | {viewContext}_audiences-tile | one of "new-visitors", "returning-visitors", "publishers", "all-users", or empty | Element visibility | User views an insufficient permissions audience tile error |
| insufficient_permissions_error_request_access | {viewContext}_audiences-tile | one of "new-visitors", "returning-visitors", "publishers", "all-users", or empty | Click | User clicks "Request access" on the error |
| data_loading_error | {viewContext}_audiences-tile | one of "new-visitors", "returning-visitors", "publishers", "all-users", or empty | Element visibility | User views a generic audience tile error |
| data_loading_error_retry | {viewContext}_audiences-tile | one of "new-visitors", "returning-visitors", "publishers", "all-users", or empty | Click | User clicks "Retry" on the error |
| view_tile_tooltip | {viewContext}_audiences-tile | one of "new-visitors", "returning-visitors", "publishers", "all-users", or empty | click/hover | User views the tooltip for an audience tile |
| view_tile_partial_data_tooltip | {viewContext}_audiences-tile | one of "new-visitors", "returning-visitors", "publishers", "all-users", or empty | click/hover | User views the tooltip for a partial data badge for an audience tile |
| view_top_content_partial_data_tooltip | {viewContext}_audiences-tile | one of "new-visitors", "returning-visitors", "publishers", "all-users", or empty | click/hover | User views the tooltip for a partial data badge in the "Top content" area of an audience tile |
| view_tile_collecting_data | {viewContext}_audiences-tile | one of "new-visitors", "returning-visitors", "publishers", "all-users", or empty | Element visibility | User views the "collecting data" tile variant for an audience tile |
| temporarily_hide | {viewContext}_audiences-tile | one of "new-visitors", "returning-visitors", "publishers", "all-users", or empty | Click | User clicks "temporarily hide" on the tile |
| insufficient_permissions_error | {viewContext}_audiences-all-tiles | Element visibility | User views the insufficient permissions full width error | |
| insufficient_permissions_error_request_access | {viewContext}_audiences-all-tiles | Click | User clicks "Request access" on the error | |
| data_loading_error | {viewContext}_audiences-all-tiles | Element visibility | User views the generic full width error | |
| data_loading_error_retry | {viewContext}_audiences-all-tiles | Click | User clicks "Retry" on the error |
Implementation Brief
- [ ] Refactor the
AudienceTileErrorcomponent to be a module with its own folder and anindex.jsfile. - [ ] Extract the rendered JSX content from the
AudienceTileErrorcomponent to a new component e.g.TileErrorContent.- Wrap the
TileErrorContentcomponent inforwardRef()so arefcan be passed to it, and add therefto its top-level rendered element. - Add an
onRetryprop of typePropTypes.functoTileErrorContent, and pass it through toReportErrorActions.
- Wrap the
- [ ] In the
AudienceTileErrorcomponent:- Add an
audienceSlugprop of typePropTypes.string. - Create a version of
TileErrorContentwrapped by thewithIntersectionObserver()HOC, e.g.TileErrorContentWithIntersectionObserver. Render this in place of the existingTileErrorContentinstance. - Pass the
onInViewcallback prop toTileErrorContentWithIntersectionObserver:- Determine the action for the GA event:
insufficient_permissions_errorfor an insufficient permissions error, ordata_loading_errorfor any other error. - Call
trackEvent( '${viewContext}_audiences-tile', action, audienceSlug ).
- Determine the action for the GA event:
- Pass the
onRetrycallback prop toTileErrorContent:- Determine the action for the GA event:
insufficient_permissions_error_request_accessfor an insufficient permissions error, ordata_loading_error_retryfor any other error. - Call
trackEvent( '${viewContext}_audiences-tile', action, audienceSlug ).
- Determine the action for the GA event:
- Add an
- [ ] Add an
onOpenprop of typePropTypes.functo both theInfoTooltipandTooltipcomponents. Pass the prop through fromInfoTooltiptoTooltiptoMuiTooltip. - [ ] Add an
onTooltipOpenprop of typePropTypes.functo theBadgeWithTooltipcomponent. Pass the prop through as theonOpenprop toInfoTooltip. - [ ] In the
AudienceTilecomponent:- Add an
audienceSlugprop of typePropTypes.stringand pass it through to theAudienceTilePagesMetriccomponent. - Pass the
onOpencallback prop toInfoTooltip. In the callback, calltrackEvent( '${viewContext}_audiences-tile', 'view_tile_tooltip', audienceSlug ). - Pass the
onTooltipOpencallback prop toBadgeWithTooltip. In the callback, calltrackEvent( '${viewContext}_audiences-tile', 'view_tile_partial_data_tooltip', audienceSlug ).
- Add an
- [ ] In the
AudienceTilePagesMetriccomponent:- Add an
audienceSlugprop of typePropTypes.string. - Pass the
onTooltipOpencallback prop toBadgeWithTooltip. In the callback, calltrackEvent( '${viewContext}_audiences-tile', 'view_top_content_partial_data_tooltip', audienceSlug ).
- Add an
- [ ] In the
AudienceTilescomponent:- Pass the
audienceSlugprop to theAudienceTileandAudienceTileErrorcomponents with the value of theaudienceSlugconstant.
- Pass the
- [ ] Create a new
AudienceTileZeroDatacomponent. MakeAudienceTileZeroDataa module with its ownindex.jsfile and create another component,TileZeroDataContentin the module folder. - [ ] Extract the JSX content for the zero-data tile variant from the
AudienceTilecomponent to the newTileZeroDataContentcomponent.- Wrap the
TileZeroDataContentcomponent inforwardRef()so arefcan be passed to it, and add therefto its top-level rendered element.
- Wrap the
- [ ] In the
AudienceTileZeroDatacomponent:- Add an
audienceSlugprop of typePropTypes.string. - Create a version of
TileZeroDataContentwrapped by thewithIntersectionObserver()HOC, e.g.TileZeroDataContentWithIntersectionObserver. Render theTileZeroDataContentWithIntersectionObservercomponent. - Pass the
onInViewcallback prop toTileZeroDataContentWithIntersectionObserver. In the callback, calltrackEvent( '${viewContext}_audiences-tile', 'view_tile_collecting_data', audienceSlug ). - Create a
handleHideTile()callback:- Call
trackEvent( '${viewContext}_audiences-tile', 'temporarily_hide', audienceSlug ), followed byonHideTile(). Chain the two calls using.finally().
- Call
- Replace
onHideTilewithhandleHideTileas the value for theonHideTileprop that is passed toTileZeroDataContentWithIntersectionObserver.
- Add an
- [ ] Refactor the
AudienceSegmentationErrorWidgetcomponent to be a module with its own folder and anindex.jsfile. - [ ] Extract the rendered JSX content from the
AudienceSegmentationErrorWidgetcomponent to a new component e.g.ErrorWidgetContent.- Wrap the
ErrorWidgetContentcomponent inforwardRef()so arefcan be passed to it, and add therefto its top-level rendered element.
- Wrap the
- [ ] In the
AudienceSegmentationErrorWidgetcomponent:- Create a version of
ErrorWidgetContentwrapped by thewithIntersectionObserver()HOC, e.g.ErrorWidgetContentWithIntersectionObserver. Render this in place of the existingErrorWidgetContentinstance. - Pass the
onInViewcallback prop toErrorWidgetContentWithIntersectionObserver:- Determine the action for the GA event:
insufficient_permissions_errorfor an insufficient permissions error, ordata_loading_errorfor any other error. - Call
trackEvent( '${viewContext}_audiences-all-tiles', action ).
- Determine the action for the GA event:
- Amend the
handleRetry()callback:- Determine the action for the GA event:
insufficient_permissions_error_request_accessfor an insufficient permissions error, ordata_loading_error_retryfor any other error. - Call
trackEvent( '${viewContext}_audiences-all-tiles', action )prior to the calls tosetValue()andonRetry(). Chain the calls usingtrackEvent().finally().
- Determine the action for the GA event:
- Create a version of
Test Coverage
- Add JS test coverage for the above changes where tests exist for the affected components.
QA Brief
Changelog entry
IB ✅
QA Update ⚠
Couple of questions:
ITEM 1:
From the AC, for {viewContext}_audiences-tile view_tile_partial_data_tooltip, is it still valid?
From https://github.com/google/site-kit-wp/issues/8144#event-14208851247, it feels like Partial Data badge has been removed.
Unless I am wrong, could you add the steps to simulate this please?
ITEM 2: Per the AC, one of the labels mentioned is "publishers". Could you clarify when "publishers" would appear as the label? From my testing, I had "purchasers" instead whenever I use the 'Purchasers' tiles.
Hi @kelvinballoo! To answer your q's:
- Item 1: The partial data badge is still relevant and will be shown for audiences other than the "new visitors" and "returning visitors" audiences as we treat them as a special case as discussed in #8144. So, in order to show the partial data badge and test this case, use the default or user-defined audiences. The label in the AC should not have included the "new-visitors" and "returning-visitors" values, this was an oversight and I've amended it to removed them.
- Item 2: This was a typo and it should have been "purchasers", I've amended this too in the AC. Thanks for spotting these, sorry for the confusion!
QA Update ✅
All the events are firing as expected. Moving ticket to Approval.
-
insufficient_permissions_error
- {viewContext}_audiences-tile - insufficient_permissions_error - one of "new-visitors", "returning visitors", "purchasers", "all-users", or empty.
-
insufficient_permissions_error_request_access
{viewContext}_audiences-tile insufficient_permissions_error_request_access one of "new-visitors", "returning-visitors", "purchasers", "all-users", or empty -
data_loading_error
{viewContext}_audiences-tile data_loading_error one of "new-visitors", "returning-visitors", "purchasers", "all-users", or empty
-
data_loading_error_retry
{viewContext}_audiences-tile data_loading_error_retry one of "new-visitors", "returning-visitors", "purchasers", "all-users", or empty -
view_tile_tooltip
{viewContext}_audiences-tile view_tile_tooltip one of "new-visitors", "returning-visitors", "purchasers", "all-users", or empty -
view_tile_partial_data_tooltip
{viewContext}_audiences-tile view_tile_partial_data_tooltip one of "new-visitors", "returning-visitors", "purchasers", "all-users", or empty -
view_top_content_partial_data_tooltip
{viewContext}_audiences-tile view_top_content_partial_data_tooltip one of "new-visitors", "returning-visitors", "purchasers", "all-users", or empty -
view_tile_collecting_data
{viewContext}_audiences-tile view_tile_collecting_data one of "new-visitors", "returning-visitors", "purchasers", "all-users", or empty -
temporarily_hide
{viewContext}_audiences-tile temporarily_hide one of "new-visitors", "returning-visitors", "purchasers", "all-users", or empty -
insufficient_permissions_error
{viewContext}_audiences-all-tiles insufficient_permissions_error -
insufficient_permissions_error_request_access
{viewContext}_audiences-all-tiles insufficient_permissions_error_request_access -
data_loading_error
{viewContext}_audiences-all-tiles data_loading_error -
data_loading_error_retry
{viewContext}_audiences-all-tiles data_loading_error_retry