site-kit-wp icon indicating copy to clipboard operation
site-kit-wp copied to clipboard

Implement/refactor GA tracking events for help menu and URL search

Open felixarntz opened this issue 5 years ago • 7 comments

Feature Description


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

Acceptance criteria

  • The click_outgoing_link GA event in the global_help_menu category should have its category adjusted to use {viewContext}_headerbar_helpmenu instead, where {viewContext} should be the current view context (see #4006 for related infrastructure).
  • The help menu feature tour (also using global_help_menu as GA event category currently) should have its category adjusted to dashboard_headerbar_helpmenu (using VIEW_CONTEXT_DASHBOARD for the "dashboard" part). If straightforward, it would be actually preferable to also use {viewContext}_headerbar_helpmenu here (so that it automatically uses the current context), however hard-coding VIEW_CONTEXT_DASHBOARD is acceptable since the feature tour can currently only render there anyway.
  • A new GA event open_urldetails should 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_DASHBOARD for 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 useContext hook to get the viewContext for the component:
import  ViewContextContext  from  'assets/js/components/Root/ViewContextContext';
import  {  useContext  }  from  '@wordpress/element';

const viewContext = useContext( ViewContextContext );
  • Refactor the call to trackEvent so that the category (first argument) is ${viewContext}_headerbar_helpmenu instead of 'global_help_menu'

Inside assets/js/components/TourTooltips.js:

  • As above, use the useContext hook and the ViewContextContext to determine the component's viewContext.

  • Add the following logic to the trackAllTourEvents function:

    • Create a variable, eventCategory
    • test the typeof gaEventCategory. If it is a 'function', call the function, passing in the viewContext as an argument. Assign the result to eventCategory.
    • Otherwise, fall back to the default, current behaviour and assign gaEventCategory
    • Refactor the rest of the logic in this function, replacing gaEventCategory references with the new eventCategory variable.
    • Update the documentation for the trackAllTourEvents function to reflect that gaEventCategory can now be a string or a function that takes the viewContext string and returns a string.
  • 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 gaEventCategory instead of a string

Inside assets/js/feature-tours/help-visibility.js:

  • refactor the gaEventCategory property to be a function that takes a viewContext string and returns the following string: ${viewContext}_headerbar_helpmenu

Inside assets/js/googlesitekit/widgets/components/URLSearchWidget.js:

  • Import trackEvent from assets/js/util/tracking/index.js
  • As above, use the useContext hook and the ViewContextContext to determine the component's viewContext.
  • Inside the onClick callback, before the call to navigateTo, call trackEvent( 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

felixarntz avatar Sep 15 '21 23:09 felixarntz

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 avatar Sep 22 '21 14:09 eugene-manuilov

@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.

johnPhillips avatar Sep 22 '21 16:09 johnPhillips

Ok, then IB :heavy_check_mark:

eugene-manuilov avatar Sep 22 '21 17:09 eugene-manuilov

QA: :heavy_multiplication_x:

This did not quite pass. See the following.

  • :white_check_mark: click_outgoing_links events are being fired with the correct {viewContext}_headerbar_helpmenu event category with the viewContext being correctly inferred as dashboard. module and pageDasboard accordingly.
  • :x: open_urldetails is firing with just the dashboard as category instead of dashboard_urlsearch-widget.
    • Screenshot_20211005_052832
  • :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

kuasha420 avatar Oct 04 '21 23:10 kuasha420

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 avatar Oct 05 '21 10:10 eugene-manuilov

@eugene-manuilov the follow-up PR has been merged 👍

@kuasha420 would you please give this another pass on main?

aaemnnosttv avatar Oct 05 '21 14:10 aaemnnosttv

QA: :heavy_check_mark:

Tested on main. LGTM!

  • :white_check_mark: click_outgoing_links events are being fired with the correct {viewContext}_headerbar_helpmenu event category with the viewContext being correctly inferred as dashboard. module and pageDasboard accordingly.
  • :white_check_mark: open_urldetails is firing with the dashboard_urlsearch-widget as category instead of dashboard_urlsearch-widget.
    • Screenshot_20211006_002321
  • :white_check_mark: Feature Tour tooltip is also using the new Event category.
    • Screenshot_20211006_002022

kuasha420 avatar Oct 05 '21 18:10 kuasha420