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

Ensure the "Top content" CTA for creating the custom dimension appears when the corresponding report error shows the custom dimension is missing #9218

Closed
10 tasks
techanvil opened this issue Aug 21, 2024 · 7 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 Aug 21, 2024

Feature Description

The Audience Tile's "Top content" metric area has a CTA for creating the googlesitekit_post_type custom dimension if it doesn't exist.

However, it doesn't have logic in place to determine if the custom dimension doesn't exist when requesting the report for the metric. At present it's reliant on the list of available custom dimensions being synced somewhere, which only happens during Audience Segmentation setup, or in the Key Metrics feature.

We should ensure that, if the report for the "Top content" metric returns an error because the custom dimension doesn't exist, the list of custom dimensions is resynced so the tile will immediately know that the dimension is missing and show the CTA to create it.


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

Acceptance criteria

  • If the reports for the Audience Tile's "Top content" metric return an error because the custom dimension doesn't exist:

Implementation Brief

Add Missing Custom Dimension to Top Content Report

  • Add the googlesitekit_post_type dimension filter to the top content report options:
 dimensionFilters: { 
 	'customEvent:googlesitekit_post_type': { 
 		filterType: 'stringFilter', 
 		matchType: 'EXACT', 
 		value: 'post', 
 	}, 
 }, 

const topContentReportOptions = {
startDate,
endDate,
dimensions: [ 'pagePath' ],
metrics: [ { name: 'screenPageViews' } ],
orderby: [ { metric: { metricName: 'screenPageViews' }, desc: true } ],
limit: 3,
};

const topContentPageTitlesReportOptions = {
startDate,
endDate,
dimensions: [ 'pagePath', 'pageTitle' ],
metrics: [ { name: 'screenPageViews' } ],
orderby: [ { metric: { metricName: 'screenPageViews' }, desc: true } ],
limit: 15,
};

Authenticated User Context

View-Only Context

Test Coverage

  • Update the tests that fail due to the addition of the custom dimension filter for the Top Content queries.
  • Create a VRT when the tile is in the view-only context with an invalid custom dimension error for the Top Content report.

QA Brief

Authenticated user

  • Set up Site Kit with the audienceSegmentation feature flag enabled and Analytics connected to a property which is out of the "gathering data" state.
  • Click on Enable groups to set up Audience Segmentation.
  • Archive the googlesitekit_post_type custom dimension in Analytics.
  • Return to Site Kit and clear session storage: sessionStorage.clear() in the JS console.
  • Refresh the dashboard.
  • Error messages including the phrase "Field customEvent:googlesitekit_post_type is not a valid dimension." will appear in the JS console, this is to be expected.
  • A POST request to the sync-custom-dimensions endpoint should appear in the network devtools.
  • The Update CTA should appear in the "Top content" metric area in the Audience Tiles.

View-only user

  • Having run through the steps above, share Analytics and login as a view-only user with access to the module.
  • The "Top content" metric area should not appear in the Audience Tiles.

Changelog entry

  • Ensure the "Top content" CTA for creating the googlesitekit_post_type custom dimension appears in the main dashboard when the corresponding report error indicates the missing custom dimension.
@techanvil techanvil added Module: Analytics Google Analytics module related issues P1 Medium priority Type: Enhancement Improvement of an existing feature labels Aug 21, 2024
@ivonac4 ivonac4 added the Team M Issues for Squad 2 label Aug 22, 2024
@benbowler benbowler self-assigned this Aug 27, 2024
@ivonac4 ivonac4 added the Next Up Issues to prioritize for definition label Aug 29, 2024
@benbowler benbowler removed their assignment Aug 30, 2024
@techanvil techanvil self-assigned this Sep 6, 2024
@techanvil
Copy link
Collaborator Author

Hi @benbowler, thanks for drafting this IB. A couple of points:

... selectors to monitor syncAvailableCustomDimensions selector/resolver like so:

  • As we're dispatching the fetchSyncAvailableCustomDimensions() action, this doesn't seem right. We'll probably want to use isFetchingSyncAvailableCustomDimensions(), e.g.:

const isSyncingAvailableCustomDimensions = useSelect( ( select ) =>
select( MODULES_ANALYTICS_4 ).isFetchingSyncAvailableCustomDimensions()
);

@techanvil techanvil assigned benbowler and unassigned techanvil Sep 6, 2024
@benbowler benbowler assigned techanvil and unassigned benbowler Sep 12, 2024
@techanvil
Copy link
Collaborator Author

techanvil commented Sep 12, 2024

Hi @benbowler, thanks for updating the IB. A few more points:

For the view-only context:

  • We shouldn't need to check isSyncingAvailableCustomDimensions in the AudienceTile component because the AudienceTileLoading component will be rendered instead due to including this value in the loading condition.
  • We need to filter out invalid custom dimension errors from the list that determines the individualTileErrors value, in order to avoid showing the whole tile in the error state, but still need to flag that there was an invalid custom dimension error to the AudienceTile so it can avoid rendering the "Top content" metric area.

More fundamentally, though - I've noticed the googlesitekit_post_type custom dimension is actually missing from the "Top content" report options:

const topContentReportOptions = {
startDate,
endDate,
dimensions: [ 'pagePath' ],
metrics: [ { name: 'screenPageViews' } ],
orderby: [ { metric: { metricName: 'screenPageViews' }, desc: true } ],
limit: 3,
};

const topContentPageTitlesReportOptions = {
startDate,
endDate,
dimensions: [ 'pagePath', 'pageTitle' ],
metrics: [ { name: 'screenPageViews' } ],
orderby: [ { metric: { metricName: 'screenPageViews' }, desc: true } ],
limit: 15,
};

It needs to be added as a dimension filter, like we do here, but with value: 'post':

dimensionFilters: {
'customEvent:googlesitekit_post_type': {
filterType: 'stringFilter',
matchType: 'EXACT',
value: productPostType,
},
},

This will be needed for this issue to be complete and testable, so we should include the fix here too. There's likely to be a number of tests that need updating as a result which we should factor into the estimate.

@techanvil techanvil assigned benbowler and unassigned techanvil Sep 12, 2024
@benbowler
Copy link
Collaborator

I chose to use the getErrorForSelector selector within the AudienceTile component instead of adding another new prop to this component, we could instead create a new prop such as hasTopContentCustomDimensionError instead if prefered.

I've increased the estimate a couple of bands because the scope has expanded slightly as we've discussed required fixes/additions to be able to work on this ticket.

@benbowler benbowler assigned techanvil and unassigned benbowler Sep 13, 2024
@techanvil
Copy link
Collaborator Author

Thanks @benbowler. Using getErrorForSelector() SGTM.

A small point, you've referred/linked to topCitiesReportErrors with regard to filtering out the invalid custom dimension errors, in fact they should be filtered out from topContentReportErrors and topContentPageTitlesReportErrors. I've amended that to save a round trip.

IB ✅

@kelvinballoo
Copy link
Collaborator

QA Update ⚠️

Hi @techanvil , I followed the steps but it doesn't seem like it's working as expected.

  • I've archived googlesitekit_post_type custom dimension in Analytics.

  • I used the tester plugin with the following settings

    Screenshot 2024-09-26 at 01 04 24
  • However, after running the clear session storage line and refreshing, nothing really changes.

  • Video is attached for reference:

    9218.test.failed.mov

Let me know in case I missed any steps.

@techanvil
Copy link
Collaborator Author

Hey @kelvinballoo, maybe I should have mentioned this in the QAB, but you won't be able to test this issue with the Tester plugin configured to provide mock report data. This is because the underlying code relies on the error response returned by the real request for the "Top content" data once the custom dimension has been archived.

You should be able to test this with any property which is legitimately out of the gathering data state. Please give it another try and let me know if you run into any further problems.

@techanvil techanvil removed their assignment Sep 26, 2024
@kelvinballoo
Copy link
Collaborator

QA Update ✅

Hi @techanvil , thanks.
I managed to test it with a site, despite having 0 data, it was out of the gathering state.
I was able to get the 'Update' button and in dashboard sharing view mode, the "Top content" metric area did not appear in the tiles. ✅

Clicking on 'Update' on the admin dashboard: ✅

  • recreated the googlesitekit_post_type custom dimension in Analytics
  • Update button no longer appears in admin dashboard
  • Top content metric area re-appears on dashboard sharing

This is working as expected.
Moving ticket to approval.

9218.tested.good.mov
9218.tested.good.for.sharing.mov

@kelvinballoo kelvinballoo removed their assignment Sep 27, 2024
@tofumatt tofumatt closed this as completed Oct 4, 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

6 participants