question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
johnPhillipscommented, Sep 22, 2021

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

0reactions
kuasha420commented, Oct 5, 2021

QA: ✔️

Tested on main. LGTM!

  • 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.
  • open_urldetails is firing with the dashboard_urlsearch-widget as category instead of dashboard_urlsearch-widget.
    • Screenshot_20211006_002321
  • ✅ Feature Tour tooltip is also using the new Event category.
    • Screenshot_20211006_002022
Read more comments on GitHub >

github_iconTop Results From Across the Web

Google Analytics Event Tracking Tutorial - Optimize Smart
Google Analytics event tracking allows you to track a specific user's activity with a web page element. Get the FREE ebook on 'Event...
Read more >
Using Google Analytics Event Tracking - Hallam Internet
Google Analytics Event tracking is a useful feature in Google Analytics that allows users to record interactions a website to record PDF ...
Read more >
[GA4] Automatically collected events - Analytics Help
Automatically collected events are triggered by basic interactions with your app and/or site (as indicated under the event name in the table below)....
Read more >
How to use Google Analytics Event Tracking to capture ... - V&A
It shows how Google Analytics Event Tracking has been set up to capture data whenever visitors use the various navigation features on the...
Read more >
How to Set Up Google Analytics Event Tracking - Hootsuite Blog
Step 1: Link your site to Google Analytics · Step 2: Add event tracking code to your website · Step 3: Find your...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found