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 · 4 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", "purchasers", "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", "purchasers", "all-users", or empty Click User clicks "Request access" on the error
data_loading_error {viewContext}_audiences-tile one of "new-visitors", "returning-visitors", "purchasers", "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", "purchasers", "all-users", or empty Click User clicks "Retry" on the error
view_tile_tooltip {viewContext}_audiences-tile one of "new-visitors", "returning-visitors", "purchasers", "all-users", or empty click/hover User views the tooltip for an audience tile
view_tile_partial_data_tooltip {viewContext}_audiences-tile one of "purchasers", "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", "purchasers", "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", "purchasers", "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", "purchasers", "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_tile_partial_data_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 and AudienceTileError 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:
    • 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

  • As a prerequisite for testing the events for each scenario:
    • Have a mechanism for checking tracked Analytics events ready, e.g. Tag Assistant or the Google Analytics Debugger Chrome extension.
    • Set up Site Kit with the audienceSegmentation feature flag enabled, tracking enabled, and Analytics connected using a property which is out of the gathering data state.
    • Click on Enable groups to set the feature up.

Error events

{
  "code": 403,
  "message": "Insufficient Permissions Test Error",
  "data": {
    "status": 403,
    "reason": "insufficientPermissions"
  }
}
  • Verify the insufficient_permissions_error event is tracked as per the AC for each of the error cases.
  • Click on Request access for each case and verify the insufficient_permissions_error_request_access event is tracked as per the AC.

Tooltip events

  • Click/hover the info icon by the title of an audience tile and verify the view_tile_tooltip event is tracked as per the AC.
  • Using a property with an audience in the partial data state, click/hover the info icon in the "partial data" badge at the top of an audience tile and verify the view_tile_partial_data_tooltip event is tracked as per the AC.
  • Using a property with a custom dimension audience in the partial data state, click/hover the info icon in the "partial data" badge in the "Top content" metric area of an audience tile and verify the view_top_content_partial_data_tooltip event is tracked as per the AC.

"Collecting data" events

  • Using a property with an audience in the partial data state, and zero data for the audience, verify the view_tile_collecting_data event is tracked when the "Site Kit is collecting data for this group." tile variant is shown as per the AC.
  • Click on Temporarily hide for the audience and verify the temporarily_hide event is tracked as per the AC.

Changelog entry

  • Add opt-in user activity tracking in the audience tiles area.
@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
@nfmohit nfmohit self-assigned this Oct 24, 2024
@nfmohit
Copy link
Collaborator

nfmohit commented Oct 24, 2024

IB ✅

@nfmohit nfmohit removed their assignment Oct 24, 2024
@techanvil techanvil self-assigned this Oct 25, 2024
@techanvil techanvil removed their assignment Oct 28, 2024
@nfmohit nfmohit assigned nfmohit and unassigned nfmohit Nov 1, 2024
@kelvinballoo kelvinballoo self-assigned this Nov 11, 2024
@kelvinballoo
Copy link
Collaborator

QA Update ⚠

Couple of questions:

ITEM 1:
From the AC, for {viewContext}_audiences-tile view_tile_partial_data_tooltip, is it still valid?
From #8144 (comment), 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.

@techanvil
Copy link
Collaborator Author

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 Handle the special case for “new visitors” and “returning visitors” to avoid the “partial data” state in the Audience Tile #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!

@techanvil techanvil removed their assignment Nov 11, 2024
@kelvinballoo
Copy link
Collaborator

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

    Image.

  • insufficient_permissions_error_request_access

    {viewContext}_audiences-tile insufficient_permissions_error_request_access one of "new-visitors", "returning-visitors", "purchasers", "all-users", or empty

    Image

  • data_loading_error

    {viewContext}_audiences-tile data_loading_error one of "new-visitors", "returning-visitors", "purchasers", "all-users", or empty

    Image

  • data_loading_error_retry

    {viewContext}_audiences-tile data_loading_error_retry one of "new-visitors", "returning-visitors", "purchasers", "all-users", or empty

    Image

  • view_tile_tooltip

    {viewContext}_audiences-tile view_tile_tooltip one of "new-visitors", "returning-visitors", "purchasers", "all-users", or empty

    Image

    Image

  • view_tile_partial_data_tooltip

    {viewContext}_audiences-tile view_tile_partial_data_tooltip one of "new-visitors", "returning-visitors", "purchasers", "all-users", or empty

    Image

    Image

  • 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

    Image

  • view_tile_collecting_data

    {viewContext}_audiences-tile view_tile_collecting_data one of "new-visitors", "returning-visitors", "purchasers", "all-users", or empty

    Image

  • temporarily_hide

    {viewContext}_audiences-tile temporarily_hide one of "new-visitors", "returning-visitors", "purchasers", "all-users", or empty

    Image

  • insufficient_permissions_error

    {viewContext}_audiences-all-tiles insufficient_permissions_error

    Image

  • insufficient_permissions_error_request_access

    {viewContext}_audiences-all-tiles insufficient_permissions_error_request_access

    Image

  • data_loading_error

    {viewContext}_audiences-all-tiles data_loading_error

    Image

  • data_loading_error_retry

    {viewContext}_audiences-all-tiles data_loading_error_retry

    Image

@kelvinballoo kelvinballoo removed their assignment Nov 12, 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

4 participants