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

Handle the special case for “new visitors” and “returning visitors” to avoid the “partial data” state in the Audience Tile #8144

Closed
3 of 13 tasks
techanvil opened this issue Jan 24, 2024 · 17 comments
Labels
Module: Analytics Google Analytics module related issues P1 Medium priority Team M Issues for Squad 2 Type: Enhancement Improvement of an existing feature

Comments

@techanvil
Copy link
Collaborator

techanvil commented Jan 24, 2024

Feature Description

Implement the special case for “new visitors” and “returning visitors” on the Audience Tile whereby their metrics are retrieved using the newVsReturning dimension instead of via the audience until the corresponding audiences are out of the "partial data" state.

See special case to avoid "partial data" state in the design doc.


Do not alter or remove anything below. The following sections will be managed by moderators only.

Acceptance criteria

  • If either of the “new visitors” and “returning visitors” audiences are determined to be in the "partial data" state (see Add “partial data” states infrastructure #8141):
    • The Audience Tile metrics for “new visitors” and “returning visitors” should be retrieved via a report that uses the newVsReturning dimension rather than audienceResourceName.
    • These metrics should reflect the full data available for the property over the current date range rather than the limited data available for the corresponding audiences.
    • The "partial data" badge at the top of these Audience Tiles should not be displayed.

Implementation Brief

Inside AudienceTilesWidget component assets/js/modules/analytics-4/components/audience-segmentation/dashboard/AudienceTilesWidget.js.

  • Use the getConfiguredSiteKitAndOtherAudiences selector added in Handle error of user count retrieval for audiences in partial data state #8923 which should return [ otherAudiences, siteKitAudiences ] in response.
  • Check if siteKitAudiences are in partial data state using hasAudiencePartialData( audiences ) selector added in Handle error of user count retrieval for audiences in partial data state #8923. Assign the result to a constant isSiteKitAudiencePartialData.
  • If isSiteKitAudiencePartialData is true:
    • Create a new report for siteKitAudiencesReport which should be fetched with same reportOptions, but using the newVsReturning dimension instead of audienceResourceName, and filtering for the values 'new' or 'returning' for this dimension (i.e. to exclude '(not set)').
    • Fetch the top cities, top content and top content titles for siteKitAudienceResourceNames separately with dimensionFilters set to newVsReturning.
    • Create a function getAudienceTileMetrics inside AudienceTilesWidget which should be called when we are iterating over the visibleAudiences to return AudienceTile component. It should return these metrics so that those can be passed to AudienceTile component.
      • This function should accept audienceResourceName as argument. It should check if isSiteKitAudiencePartialData is true.
        • If isSiteKitAudiencePartialData is true and the audienceResourceName belongs to a Site Kit audience (use the isSiteKitAudience selector), return the data from the report fetched for Site Kit audiences which used newVsReturning dimension.
        • Otherwise, return the metrics from the main, existing report that uses the audienceResourceName dimension.
  • In AudienceTile component inside assets/js/modules/analytics-4/components/audience-segmentation/dashboard/AudienceTile/index.js
    • While determining isAudiencePartialData, use the isSiteKitAudience selector to check if the audienceResourceName Site Kit audience.
    • If property is not in partial state and audience belongs to one of the above, return false.
    • If property is not in partial state or audience is non Site-Kit audience, and in partial state, then return true.

Test Coverage

  • Add the test coverage for the scenario where "new visitors" and "returning visitors" are in partial data states.

QA Brief

Prerequisites

  • Set up Analytics and enable the audienceSegmentation feature flag.
  • Ensure the audiences are enabled and available in the Audience widget area.
  • Ensure "new visitors" and "returning visitors" audiences are visible in the Audience widget area.
  • Ensure "new visitors" and "returning visitors" audiences are in a partial data state.

Data Verification

  • Visit the Audience widget area.
  • Verify that the Audience Tiles for "new visitors" and "returning visitors" display the data from the newVsReturning dimension rather than the audienceResourceName dimension.
  • Verify that the Audience Tiles for "new visitors" and "returning visitors" are not displaying the "partial data" badge for the main report metrics.
  • The "Top content by pageviews" sections will have the "partial data" badge displayed if the corresponding audiences are in partial data state.

Testing the Error State

Changelog entry

  • Handle the “new visitors” and “returning visitors” audiences as a special case to avoid the "partial data" state for them on the Audience Tiles.
@techanvil techanvil added Module: Analytics Google Analytics module related issues P1 Medium priority Type: Enhancement Improvement of an existing feature labels Jan 24, 2024
@techanvil
Copy link
Collaborator Author

Note that I've moved this to the Backlog as we have an open discussion on the "collecting data" terminology in the design doc.

@techanvil techanvil changed the title Handle the special case for “new visitors” and “returning visitors” to avoid the “collecting data” state in the Audiences Tile Handle the special case for “new visitors” and “returning visitors” to avoid the “partial data” state in the Audiences Tile Feb 8, 2024
@techanvil
Copy link
Collaborator Author

The aforementioned discussion has been resolved, and this is ready for AC.

@techanvil techanvil assigned techanvil and unassigned techanvil Mar 15, 2024
@ivonac4 ivonac4 added the Team M Issues for Squad 2 label Apr 9, 2024
@ivonac4 ivonac4 added the Next Up Issues to prioritize for definition label May 24, 2024
@ankitrox ankitrox assigned ankitrox and unassigned ankitrox May 28, 2024
@techanvil techanvil self-assigned this May 30, 2024
@techanvil techanvil changed the title Handle the special case for “new visitors” and “returning visitors” to avoid the “partial data” state in the Audiences Tile Handle the special case for “new visitors” and “returning visitors” to avoid the “partial data” state in the Audience Tile May 31, 2024
@techanvil
Copy link
Collaborator Author

Hi @ankitrox, thanks for drafting this IB.

You raise an interesting concern as to how this issue relates to #8726. On balance, I think it would in fact be preferable to wait for #8726 to be implemented before tackling this issue, as #8726 will result in some significant refactoring of the AudienceTilesWidget and AudienceTile components, which I think would further impact this issue (for example I don't think the specced getMetric() would be relevant any more, and the data extraction aspect this addresses would need to be tackled in AudienceTile instead).

It's also the case that if we implement this issue before #8726, then #8726 itself will be impacted and require additional work that we haven't accounted for in its IB.

In terms of execution efficiency I think the refactor specced in #8726 would be better done first because it will simplify the data extraction, and lead to a fairly straightforward implementation for this issue, whereas if we implement this issue first we'll add complexity to the data extraction side of things which will be a bit harder to subsequently refactor in #8726.

So, as a result I've added #8726 as a blocker to this issue, and would suggest revisiting the IB here with this in mind.

Here are a few additional points on the current IB:

  • A minor one, I'd suggest a couple of renames:
    • isSiteKitAudiencePartial -> isSiteKitAudiencePartialData
    • siteKitAudiencesResourceNames -> siteKitAudienceResourceNames, if we keep the variable. It's not entirely clear what this variable will be used for, so please can you either clarify or remove this from the spec?

  • While determining isAudiencePartialData, check if the audienceResourceName belongs to "new visitors" or "returning visitors".
  • This is OK, but it could be worth a mention of the isSiteKitAudience() selector which we can use for an easy check here.

  • If property is not in partial state or audience is non Site-Kit audience, and in partial state, then return true.
  • It looks like the "or" here should be an "and", i.e. "If property is not in partial state and the audience is non Site-Kit audience"...

@techanvil techanvil assigned ankitrox and unassigned techanvil May 31, 2024
@ivonac4 ivonac4 removed the Next Up Issues to prioritize for definition label Jun 3, 2024
@ankitrox ankitrox removed their assignment Jun 18, 2024
@ivonac4 ivonac4 added the Next Up Issues to prioritize for definition label Jun 19, 2024
@ankitrox ankitrox assigned ankitrox and techanvil and unassigned ankitrox Jun 24, 2024
@ankitrox
Copy link
Collaborator

Thank you @techanvil .

As we have pretty much implemented #8484 and #8726 is also in CR, I've written the IB for this one. Requesting you to kindly review the same.

Thanks

@techanvil
Copy link
Collaborator Author

Thanks @ankitrox! The IB is most of the way there. A couple of smallish points:

  • The audienceResourceName property is the name of an audience and looks something like properties/433726123/audiences/8044127456. The IB has it mixed up with audienceSlug which will have the values new-visitors, returning-visitors etc.
    • This means that in AudienceTilesWidget we'll need to do an extra lookup to retrieve the audienceSlug for an audience rather than comparing audienceResourceName directly as specified.
    • In AudienceTiles we can use the isSiteKitAudience() selector which accepts an audienceResourceName argument.
  • Please update AudienceTiles to be AudienceTilesWidget which is the name of the component.

@techanvil techanvil assigned ankitrox and unassigned techanvil Jun 27, 2024
@ankitrox
Copy link
Collaborator

Thank you @techanvil . I have updated the IB for the points mentioned.

Assigning to you for review.

@hussain-t hussain-t removed their assignment Sep 9, 2024
@techanvil techanvil assigned hussain-t and unassigned techanvil Sep 9, 2024
@ivonac4
Copy link
Collaborator

ivonac4 commented Sep 10, 2024

Hussain flagged this will go over the estimate a bit due to increased complexity.

@hussain-t hussain-t assigned techanvil and unassigned hussain-t Sep 10, 2024
techanvil added a commit that referenced this issue Sep 10, 2024
…-returning-visitors

Enhancement/#8144 - Handle “new visitors” and “returning visitors” to avoid the “partial data” state
@techanvil techanvil removed their assignment Sep 10, 2024
@hussain-t hussain-t assigned hussain-t and unassigned kelvinballoo Sep 11, 2024
@hussain-t hussain-t assigned techanvil and unassigned hussain-t Sep 11, 2024
techanvil added a commit that referenced this issue Sep 11, 2024
…ructure-follow-up

Fix array destructuring with fallback to prevent crashing when `getAudienceUserCountReportErrors` returns `undefined`
@techanvil techanvil assigned hussain-t and unassigned techanvil Sep 11, 2024
@hussain-t hussain-t assigned kelvinballoo and unassigned hussain-t Sep 11, 2024
@wpdarren wpdarren assigned wpdarren and unassigned kelvinballoo Sep 18, 2024
@wpdarren
Copy link
Collaborator

QA Update: ✅

Verified:

  • Audience Tiles for new visitors and returning visitors display the data from the newVsReturning dimension. I ran through the report in GA4 and compared this with data for 7, 14, 28 and 90 days.
  • Audience Tiles for new visitors and returning visitors are not displaying the partial data badge for the report.
  • The Top content by pageviews sections has the partial data badge displayed if in partial data state.
  • The two errors (full and single) appeared as expected.. I tested this on another live site, and also checked to make sure that new and returning visitors functioned the same with different setup in Tweak extension. See screenshots.
Screenshots

image
image
image
image
image

@wpdarren wpdarren removed their assignment Sep 18, 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 P1 Medium priority Team M Issues for Squad 2 Type: Enhancement Improvement of an existing feature
Projects
None yet
Development

No branches or pull requests

8 participants