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

GA4 dashboard prompt banner reappears when toggling from GA4 > UA > GA4 even if "Maybe later" is selected #6932

Closed
mxbclang opened this issue Apr 19, 2023 · 7 comments
Labels
Exp: SP Module: Analytics Google Analytics module related issues P1 Medium priority Type: Enhancement Improvement of an existing feature

Comments

@mxbclang
Copy link

mxbclang commented Apr 19, 2023

Bug Description

As reported by @adamdunnage in Bug Bash:

The user will always be prompted with the activate GA4 reporting Dashboard banner when toggling between UA/GA4 dashboards even if they have selected 'maybe later' option previously.

Although an edge case we will see some users switching between the two for different reasons and if they have previously selected the 'maybe later' option then I believe the banner shouldn't display.

You can see this in the recording below:

https://www.loom.com/share/22c7aade0fd6413c8f0a6f074577254c


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

Acceptance criteria

  • If the user has ever had the GA4 Dashboard active, but then switches to the UA dashboard, they should never see the banner notification to activate GA4 Dashboard. Given they disabled it, they know it exists, so the notification should never appear if the GA4 Dashboard was ever enabled previously, even if they had never seen the notification before.

Implementation Brief

In assets/js/components/notifications/SwitchGA4DashboardViewNotification.js:

  • Use the isItemDismissed selector from the core/user store to check whether the notification has already been dismissed.
  • Return null if the notification has already been dismissed. Alternatively, update the useSelect statement for shouldPromptGA4DashboardView to return false if the GA4 Dashboard activation notification has already been dismissed.
  • Update the handleCTAClick callback to dispatch the dismissItem action of the core/user store and pass the notification ID (switch-ga4-dashboard-view) to it.

In assets/js/modules/analytics/datastore/settings.js, update the submitChanges action:

  • Check if there are no errors when saving the settings AND if the ga4Reporting feature flag is enabled AND the dashboard view is already GA4:
    • Dispatch the dismissItem action of the core/user store and pass the notification ID to it.

Test Coverage

  • No new tests are to be added.

QA Brief

  • Enable the ga4Reporting feature flag.
  • Switch to the UA Dashboard view.
  • When the SwitchGA4DashboardViewNotification appears, click the Update dashboard CTA and verify that the notification is dismissed permanently. This can be tested by switching the dashboard view back and forth and verifying that the notification does not appear again.
  • Delete switch-ga4-dashboard-view item from the wp_usermeta table with the meta_key wp_googlesitekitpersistent_dismissed_items and verify that the notification appears again.
  • Verify the same behavior by clicking the Maybe later button.
  • Verify the same behavior by switching the dashboard view from the settings page.

Changelog entry

  • Prevent the "Switch to GA4" CTA from appearing when the user has manually switched away from the GA4 dashboard view.
@mxbclang mxbclang added P1 Medium priority Type: Enhancement Improvement of an existing feature Module: Analytics Google Analytics module related issues labels Apr 19, 2023
@tofumatt tofumatt assigned tofumatt and unassigned tofumatt Apr 20, 2023
@hussain-t hussain-t self-assigned this Apr 25, 2023
@hussain-t hussain-t removed their assignment May 8, 2023
@eugene-manuilov eugene-manuilov self-assigned this May 9, 2023
@eugene-manuilov
Copy link
Collaborator

@hussain-t, I believe we should dismiss the notification banner in the submitChanges action to ensure that banner is dismissed when the user changes the dashboard view on the settings page as well.

@hussain-t
Copy link
Collaborator

Thanks, @eugene-manuilov. I have updated the IB.

@eugene-manuilov
Copy link
Collaborator

@hussain-t, I meant dismissing it here:

export async function submitChanges( registry ) {
const { select, dispatch } = registry;
const ga4ReportingEnabled = isFeatureEnabled( 'ga4Reporting' );
const isUAEnabled = select( CORE_FORMS ).getValue( FORM_SETUP, 'enableUA' );
let propertyID = select( MODULES_ANALYTICS ).getPropertyID();
if (
( ! ga4ReportingEnabled || isUAEnabled ) &&
propertyID === PROPERTY_CREATE
) {
const accountID = select( MODULES_ANALYTICS ).getAccountID();
const { response: property, error } = await dispatch(
MODULES_ANALYTICS
).createProperty( accountID );
if ( error ) {
return { error };
}
propertyID = property.id;
dispatch( MODULES_ANALYTICS ).setPropertyID( property.id );
dispatch( MODULES_ANALYTICS ).setInternalWebPropertyID(
// eslint-disable-next-line sitekit/acronym-case
property.internalWebPropertyId
);
}
const profileID = select( MODULES_ANALYTICS ).getProfileID();
if (
( ! ga4ReportingEnabled || isUAEnabled ) &&
profileID === PROFILE_CREATE
) {
const profileName = select( CORE_FORMS ).getValue(
FORM_SETUP,
'profileName'
);
const accountID = select( MODULES_ANALYTICS ).getAccountID();
const { response: profile, error } = await dispatch(
MODULES_ANALYTICS
).createProfile( accountID, propertyID, { profileName } );
if ( error ) {
return { error };
}
dispatch( MODULES_ANALYTICS ).setProfileID( profile.id );
}
// If `ga4Reporting` is enabled, the dashboard view is set to UA
// and UA is not enabled, we need to set the dashboard view to GA4.
const dashboardView = select( MODULES_ANALYTICS ).getDashboardView();
if (
ga4ReportingEnabled &&
dashboardView === DASHBOARD_VIEW_UA &&
! isUAEnabled
) {
dispatch( MODULES_ANALYTICS ).setDashboardView( DASHBOARD_VIEW_GA4 );
}
const ga4PropertyID = select( MODULES_ANALYTICS_4 ).getPropertyID();
const ga4StreamID = select( MODULES_ANALYTICS_4 ).getWebDataStreamID();
if (
ga4PropertyID === GA4_PROPERTY_CREATE ||
ga4StreamID === WEBDATASTREAM_CREATE
) {
const { error } = await submitGA4Changes( registry );
if ( error ) {
return { error };
}
}
// This action shouldn't be called if settings haven't changed,
// but this prevents errors in tests.
if ( select( MODULES_ANALYTICS ).haveSettingsChanged() ) {
const { error } = await dispatch( MODULES_ANALYTICS ).saveSettings();
if ( error ) {
return { error };
}
}
await API.invalidateCache( 'modules', 'analytics' );
const { error } = await submitGA4Changes( registry );
if ( error ) {
return { error };
}
return {};
}

@hussain-t
Copy link
Collaborator

Thanks, @eugene-manuilov. I have updated the IB.

@eugene-manuilov
Copy link
Collaborator

  • Locate to code that sets the dashboard view to GA4.
  • Right after setting the dashboard view to GA4, dispatch the dismissItem action ....

Thanks, @hussain-t. This is almost good, but I think we should dismiss it only when settings are saved with no errors. Could you please update it?

@eugene-manuilov
Copy link
Collaborator

Thanks, @hussain-t. IB ✔️

@eugene-manuilov eugene-manuilov removed their assignment May 10, 2023
@hussain-t hussain-t self-assigned this May 10, 2023
hussain-t added a commit that referenced this issue May 11, 2023
@hussain-t hussain-t removed their assignment May 11, 2023
@techanvil techanvil assigned techanvil and hussain-t and unassigned techanvil May 15, 2023
@kuasha420 kuasha420 assigned kuasha420 and unassigned hussain-t May 16, 2023
@kuasha420 kuasha420 assigned techanvil and unassigned kuasha420 May 16, 2023
techanvil added a commit that referenced this issue May 16, 2023
…ard-banner

Enhance/#6932 - GA4 dashboard prompt banner notification
@techanvil techanvil removed their assignment May 16, 2023
@mohitwp mohitwp self-assigned this May 17, 2023
@mohitwp
Copy link
Collaborator

mohitwp commented May 23, 2023

QA Update ✅

-Tested on dev.
-Verified when the SwitchGA4DashboardViewNotification appears, clicking on the Update dashboard CTA dismissed notification permanently also verified that the notification not appears again when we switch dashboard views.

  • Verified when the SwitchGA4DashboardViewNotification appears, clicking on the 'Maybe later' dismissed notification permanently also verified that the notification not appears again when we switch dashboard views.
  • Verified the user has ever had the GA4 Dashboard active, but then switches to the UA dashboard, then they never see the banner notification to activate GA4 Dashboard.
Recording.375.mp4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Exp: SP Module: Analytics Google Analytics module related issues P1 Medium priority Type: Enhancement Improvement of an existing feature
Projects
None yet
Development

No branches or pull requests

8 participants