Implement/refactor GA tracking events for help menu and URL search
Feature Description
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
- The
click_outgoing_linkGA event in theglobal_help_menucategory should have its category adjusted to use{viewContext}_headerbar_helpmenuinstead, where{viewContext}should be the current view context (see #4006 for related infrastructure). - The help menu feature tour (also using
global_help_menuas GA event category currently) should have its category adjusted todashboard_headerbar_helpmenu(usingVIEW_CONTEXT_DASHBOARDfor the "dashboard" part). If straightforward, it would be actually preferable to also use{viewContext}_headerbar_helpmenuhere (so that it automatically uses the current context), however hard-codingVIEW_CONTEXT_DASHBOARDis acceptable since the feature tour can currently only render there anyway. - A new GA event
open_urldetailsshould be added to the URL search widget in the Site Kit dashboard.- It should be triggered when the user actually submits, i.e. navigates away to that URL's details page.
- The event category for this should be "dashboard_urlsearch-widget" (using
VIEW_CONTEXT_DASHBOARDfor the "dashboard" part).
- Note that these events should be present in both the old and new header bar (see #4048).
Implementation Brief
Inside assets/js/components/help/HelpMenuLink.js:
- Import the View Context from
assets/js/components/Root/ViewContextContext.js - Pass this to the
useContexthook to get theviewContextfor the component:
import ViewContextContext from 'assets/js/components/Root/ViewContextContext';
import { useContext } from '@wordpress/element';
const viewContext = useContext( ViewContextContext );
- Refactor the call to
trackEventso that the category (first argument) is${viewContext}_headerbar_helpmenuinstead of'global_help_menu'
Inside assets/js/components/TourTooltips.js:
-
As above, use the
useContexthook and theViewContextContextto determine the component'sviewContext. -
Add the following logic to the
trackAllTourEventsfunction:- Create a variable,
eventCategory - test the
typeof gaEventCategory. If it is a'function', call the function, passing in theviewContextas an argument. Assign the result toeventCategory. - Otherwise, fall back to the default, current behaviour and assign
gaEventCategory - Refactor the rest of the logic in this function, replacing
gaEventCategoryreferences with the neweventCategoryvariable. - Update the documentation for the
trackAllTourEventsfunction to reflect thatgaEventCategorycan now be a string or a function that takes theviewContextstring and returns a string.
- Create a variable,
-
Inside
assets/js/components/TourTooltips.test.js- Make sure the existing tests still pass now that the component uses context
- Add a test to cover the new scenario where a tour passes a function as
gaEventCategoryinstead of a string
Inside assets/js/feature-tours/help-visibility.js:
- refactor the
gaEventCategoryproperty to be a function that takes aviewContextstring and returns the following string:${viewContext}_headerbar_helpmenu
Inside assets/js/googlesitekit/widgets/components/URLSearchWidget.js:
- Import
trackEventfromassets/js/util/tracking/index.js - As above, use the
useContexthook and theViewContextContextto determine the component'sviewContext. - Inside the
onClickcallback, before the call tonavigateTo, calltrackEvent( viewContext, 'open_urldetails' )
Test Coverage
- As described in the IB.
QA Brief
- The help menu links and the help menu feature tour should use the new events described in the AC.
- The
URLSearchWidget(the search bar entitled 'Search for individual page or post information` on the dashboard) should use the new event as per the AC.
Changelog entry
- N/A
Note that these events should be present in both the old and new header bar (see Implement new Unified Dashboard header design/UI behind feature flag #4048).
@johnPhillips IB almost looks good to me, but AC says that we also need to add the same events to the new header bar. I am going to assign this ticket back to you. You will probably need to wait till IB for #4048 is written to be able to add the remaining part.
@eugene-manuilov I just spoke to @tofumatt and my understanding is that the final AC here is more of an FYI, as the header will likely use the same existing URL search component. I don't think it requires anything in the IB.
Ok, then IB :heavy_check_mark:
QA: :heavy_multiplication_x:
This did not quite pass. See the following.
- :white_check_mark:
click_outgoing_linksevents are being fired with the correct{viewContext}_headerbar_helpmenuevent category with theviewContextbeing correctly inferred asdashboard.moduleandpageDasboardaccordingly. - :x:
open_urldetailsis firing with just thedashboardas category instead ofdashboard_urlsearch-widget. - :grey_question: How to get The help menu feature tour? I have tried setting the initial plugin version back but it didn't bring up anything. A note about that in QAB would be appreciated.
Also, should this ticket wait for #4048? @felixarntz
Also, as John is not available and he's not available, I'm not sure whom to assign for the execution. Leaving as unassigned to Execution for now.
cc @eugene-manuilov
Good catch, @kuasha420. I have created a new pull request that fixes the GA event category issue. @aaemnnosttv do you mind reviewing #4188?
How to get The help menu feature tour? I have tried setting the initial plugin version back but it didn't bring up anything.
@kuasha420 try to delete dismissed feature tours for your user.
Also, should this ticket wait for #4048?
I'll update that ticket to reflect the required changes in the URL search component.
@eugene-manuilov the follow-up PR has been merged 👍
@kuasha420 would you please give this another pass on main?
QA: :heavy_check_mark:
Tested on main. LGTM!
- :white_check_mark:
click_outgoing_linksevents are being fired with the correct{viewContext}_headerbar_helpmenuevent category with theviewContextbeing correctly inferred asdashboard.moduleandpageDasboardaccordingly. - :white_check_mark:
open_urldetailsis firing with thedashboard_urlsearch-widgetas category instead ofdashboard_urlsearch-widget. - :white_check_mark: Feature Tour tooltip is also using the new Event category.


