Allow changing Analytics view name when creating a new view
Bug Description
Analytics new view creation duplicates default “All Web Site Data” view. No indication that the view was created, that the user needs to modify the view, or where to do it (on Analytics platform). Also referenced in #522 .
Steps to reproduce
- Go to the Analytics Module
- Click on the View dropdown and select Setup a new view
- Click on the button Confirm Changes
- After the page refreshes, the new view named “All Website Data” is selected, which is the same as the default view in Analytics.
- Navigating to the Analytics account, one gets a notification that there are “Redundant Views”
Screenshots
Duplicate All Website Data View in Site Kit

Duplicate All Website Data View in Google Analytics

Redundant View Notification in Google Analytics

Additional Context
- PHP Version: 7.1.30
- OS: MacOS
- Browser: Chrome
- Plugin Version: 1.0.0-rc.1.1
- Device: MacBook Air
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
If the user selects "Setup a new view":
- display a field below the dropdown boxes where they can name the new view something different than the default ("All website data")
- display a message "You can make changes to this view (e.g. exclude URL query parameters) in Google Analytics.", without a link.
Once the user creates the new view and saves it by clicking "configure analytics":
- in the Settings section display the same text ("You can make changes to this view (e.g. exclude URL query parameters) in Google Analytics.") and a deep link to the relevant part of GA FE where they can make more changes to the specific view (link would be in the format
https://analytics.google.com/analytics/web/?authuser={email}#/a[accountID]w[webPropertyID]p[profileID]/admin/view/settings)
Implementation Brief
- When the "Set up a new view" option is chosen during module set up or settings edit, render an additional text input for the new view name (likely right below the dropdown), which defaults to "All Web Site Data"
- The state for the input should be stored in the
core/formsdatastore under theanalyticsSetuporanalyticsSettingsformID depending on the context and passed through to thecreate-profilerequest in thesubmitChangesaction which handles the form submit for both set up and settings. - ~~Validate the view name to meet naming requirements~~
There don't appear to be any restrictions on view names - Display a warning notice if the name matches an existing view of the selected property
Look into usingleadingIconandhelperTextprops onTextFieldconditionally for this (reference) Don't prevent the user from creating a new view with the same name if they want to - Add a descriptive message (text only) below the input:
You can make changes to this view (e.g. exclude URL query parameters) in Google Analytics - Add a link to the view edit screen in Analytics to the
SettingsViewcomponent- href
https://analytics.google.com/analytics/web/?authuser={email}#/a[accountID]w[webPropertyID]p[profileID]/admin/view/settings
whereemailis the value ofselect( 'core/user' ).getEmail() - text "You can make changes to this view (e.g. exclude URL query parameters) in Google Analytics"
- href
- The state for the input should be stored in the
- Update
POST:create-profileto take a new optionalnameparameter to override the default if provided
Changelog entry
- Allow specifying Analytics view name when creating a new one, and display a deep link to modify view settings in Analytics module settings.
@marrrmarrr Any idea how we can prevent (or at least guide away) the user from doing this?
It's expected in the current plugin behavior that this theoretically is possible, but as pointed out, it might not make sense if you just set up a duplicate identical profile. I'm not even sure we can determine that, but let's think about it.
@aaemnnosttv The IB doesn't include the part about adding a message (with link if possible) to the relevant area in GA.
Extend the same behavior for creating a new property
I'm not sure I understand this part, there should not be an input field to name a new property - it only applies to a new profile.
IB ✅
@aaemnnosttv Note that the link should only be displayed if actually valid, based on the currently selected values. For example, if a dropdown is set to "Select..." or "Setup new...", there should be no link because there's no ID to include.
Moving this back as it now dependent on #1101
Now that the analytics refactoring is complete, I think this IB can be revisited and confirmed/updated to work with the new analytics code. Note that it may need to be entirely replaced from the JS side as the JS code here is totally new.
After that it can be moved to IB review. Feel free to adjust the estimate and entire IB if needed. 😄
IB updated!
IB sounds good to me, IB ✅
Tested
Installed latest develop SK, setup Analytics module. Navigating to setup and selecting 'New View'
Notice:

Clicking confirm prompts:

Ran through confirmation which landed me here:

I added 2 'a's to my View name and selected confirm
Notice:


Confirmed user can adjust and select the new view and prior default 'All Website Data'
One thing to note for consistency's sake.
Setting up a new account we use the term 'All website traffic' for the View

Adjusting in settings defaults to 'All Web Site Data'

Sending this back to @eugene-manuilov for an adjustment.
Suggesting we choose either 'All Web Site Data' or 'All website traffic' for consistency's sake.
Good catch @cole10up -
In this case I think we should change the default used by the account provisioning screen as the default name for a new view is consistent with what is in place here:

@marrrmarrr is it okay for us to change the default view name used on the new Analytics create account screen to "All Web Site Data" instead of "All website traffic"?
@aaemnnosttv Just talked to @marrrmarrr, let's make the change.
@felixarntz just to clarify, we're changing the default used in the account creation form, correct?
@aaemnnosttv Yep 👍
Retested
Confirmed the use of 'All Website Data' is now being displayed on the account provisioning screen

Ran a series of regression tests removing Analytics module, trying to setup module with the same view name (warning message displayed).

Passed QA ✅
I just ran into an error with this locally due to undefined profiles. Sending this back to execution for a quick follow-up fix.
Error
Site Kit encountered an error
Cannot read property 'some' of undefined
in ProfileNameTextField
in div
in div
in SettingsForm
in div
in SettingsEdit
in SettingsMain
in InnerComponent (created by WithFilters(ModuleSettingsDetails))
in WithFilters(ModuleSettingsDetails)
in div
in div
in div
in div
in div
in SettingsModule
in div
in Layout
in div
in SettingsModules
in div
in div
in div
in SettingsApp
in RestoreSnapshots
in ErrorHandler
in Root
Tested
Ran a series of regression tests with latest Develop focusing on new Analytics account creation, adjusting view names, proxy setup, uninstalling and reinstalling the module.
No issues on my end
Passed QA ✅