Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GA event tracking for the Audiences Tiles (excluding the "Top content" metric area) #9494

Open
14 tasks
techanvil opened this issue Oct 11, 2024 · 0 comments
Open
14 tasks
Labels
Module: Analytics Google Analytics module related issues P0 High priority Team M Issues for Squad 2 Type: Enhancement Improvement of an existing feature

Comments

@techanvil
Copy link
Collaborator

techanvil commented Oct 11, 2024

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 AudienceTileError component to be a module with its own folder and an index.js file.
  • Extract the rendered JSX content from the AudienceTileError component to a new component e.g. TileErrorContent.
    • Wrap the TileErrorContent component in forwardRef() so a ref can be passed to it, and add the ref to its top-level rendered element.
    • Add an onRetry prop of type PropTypes.func to TileErrorContent, and pass it through to ReportErrorActions.
  • In the AudienceTileError component:
    • Add an audienceSlug prop of type PropTypes.string.
    • Create a version of TileErrorContent wrapped by the withIntersectionObserver() HOC, e.g. TileErrorContentWithIntersectionObserver. Render this in place of the existing TileErrorContent instance.
    • Pass the onInView callback prop to TileErrorContentWithIntersectionObserver:
      • Determine the action for the GA event: insufficient_permissions_error for an insufficient permissions error, or data_loading_error for any other error.
      • Call trackEvent( '${viewContext}_audiences-tile', action, audienceSlug ).
    • Pass the onRetry callback prop to TileErrorContent:
      • Determine the action for the GA event: insufficient_permissions_error_request_access for an insufficient permissions error, or data_loading_error_retry for any other error.
      • Call trackEvent( '${viewContext}_audiences-tile', action, audienceSlug ).
  • Add an onOpen prop of type PropTypes.func to both the InfoTooltip and Tooltip components. Pass the prop through from InfoTooltip to Tooltip to MuiTooltip.
  • Add an onTooltipOpen prop of type PropTypes.func to the BadgeWithTooltip component. Pass the prop through as the onOpen prop to InfoTooltip.
  • In the AudienceTile component:
    • Add an audienceSlug prop of type PropTypes.string and pass it through to the AudienceTilePagesMetric component.
    • Pass the onOpen callback prop to InfoTooltip. In the callback, call trackEvent( '${viewContext}_audiences-tile', 'view_tile_tooltip', audienceSlug ).
    • Pass the onTooltipOpen callback prop to BadgeWithTooltip. In the callback, call trackEvent( '${viewContext}_audiences-tile', 'view_partial_data_tile_tooltip', audienceSlug ).
  • In the AudienceTilePagesMetric component:
    • Add an audienceSlug prop of type PropTypes.string.
    • Pass the onTooltipOpen callback prop to BadgeWithTooltip. In the callback, call trackEvent( '${viewContext}_audiences-tile', 'view_top_content_partial_data_tooltip', audienceSlug ).
  • In the AudienceTiles component:
    • Pass the audienceSlug prop to the AudienceTile, AudienceTileError and AudienceTilePagesMetric components with the value of the audienceSlug constant.
  • Create a new AudienceTileZeroData component. Make AudienceTileZeroData a module with its own index.js file and create another component, TileZeroDataContent in the module folder.
  • Extract the JSX content for the zero-data tile variant from the AudienceTile component to the new TileZeroDataContent component.
    • Wrap the TileZeroDataContent component in forwardRef() so a ref can be passed to it, and add the ref to its top-level rendered element.
  • In the AudienceTileZeroData component:
    • Add an audienceSlug prop of type PropTypes.string.
    • Create a version of TileZeroDataContent wrapped by the withIntersectionObserver() HOC, e.g. TileZeroDataContentWithIntersectionObserver. Render the TileZeroDataContentWithIntersectionObserver component.
    • Pass the onInView callback prop to TileZeroDataContentWithIntersectionObserver. In the callback, call trackEvent( '${viewContext}_audiences-tile', 'view_tile_collecting_data', audienceSlug ).
    • Create a handleHideTile() callback:
      • Call trackEvent( '${viewContext}_audiences-tile', 'temporarily_hide', audienceSlug ), followed by onHideTile(). Chain the two calls using .finally().
    • Replace onHideTile with handleHideTile as the value for the onHideTile prop that is passed to TileZeroDataContentWithIntersectionObserver.
  • Refactor the AudienceSegmentationErrorWidget component to be a module with its own folder and an index.js file.
  • Extract the rendered JSX content from the AudienceSegmentationErrorWidget component to a new component e.g. ErrorWidgetContent.
    • Wrap the ErrorWidgetContent component in forwardRef() so a ref can be passed to it, and add the ref to its top-level rendered element.
  • In the AudienceSegmentationErrorWidget component:
    • Add an audienceSlug prop of type PropTypes.string.
    • Create a version of ErrorWidgetContent wrapped by the withIntersectionObserver() HOC, e.g. ErrorWidgetContentWithIntersectionObserver. Render this in place of the existing ErrorWidgetContent instance.
    • Pass the onInView callback prop to ErrorWidgetContentWithIntersectionObserver:
      • Determine the action for the GA event: insufficient_permissions_error for an insufficient permissions error, or data_loading_error for any other error.
      • Call trackEvent( '${viewContext}_audiences-all-tiles', action ).
    • Amend the handleRetry() callback:
      • Determine the action for the GA event: insufficient_permissions_error_request_access for an insufficient permissions error, or data_loading_error_retry for any other error.
      • Call trackEvent( '${viewContext}_audiences-all-tiles', action ) prior to the calls to setValue() and onRetry(). Chain the calls using trackEvent().finally().

Test Coverage

  • Add JS test coverage for the above changes where tests exist for the affected components.

QA Brief

Changelog entry

@techanvil techanvil added Module: Analytics Google Analytics module related issues P0 High priority Type: Enhancement Improvement of an existing feature labels Oct 11, 2024
@benbowler benbowler added the Team M Issues for Squad 2 label Oct 14, 2024
@techanvil techanvil assigned techanvil and unassigned techanvil Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Module: Analytics Google Analytics module related issues P0 High priority Team M Issues for Squad 2 Type: Enhancement Improvement of an existing feature
Projects
None yet
Development

No branches or pull requests

2 participants