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

Display actual number of users coming from search in refactored "Unique Visitors (from Search)" widget

Open felixarntz opened this issue 5 years ago • 11 comments

The refactored version of the "Unique Visitors from Search" widget currently uses "Unique Visitors" title, since the widget is (and has always been 🤦‍♂️ ) displaying the total number of users. This is actually wrong, and it should display the number of users that came from Organic Search.

This is a bug in the legacy widget primarily, but it should only be fixed in the refactored version, since that will roll out anyway.


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

Acceptance criteria

  • The Analytics DashboardUniqueVisitorsWidget (visible when enabling widgets.dashboard / widgets.pageDashboard feature flags) should be updated as follows:
    • It should be renamed to DashboardSearchVisitorsWidget throughout the codebase (also related references, e.g. Storybook name).
    • Its title should be changed to "Unique Visitors from Search".
    • It should display metrics for only users that came from Organic Search instead of all users (i.e. for dimensionName of ga:channelGrouping and dimensionValue of Organic Search).
    • Its source link should be updated accordingly:
      • It should link to a specific version of the acquisition-channels report.
      • The URL's _r.drilldown argument should include analytics.trafficChannel:Organic%20Search.
      • The URL should otherwise include the current date parameters and, if relevant, the analytics.pagePath for the current entity URL within _r.drilldown.
        • Multiple _r.drilldown parameters can be included by concatenating with a comma, e.g. _r.drilldown=analytics.trafficChannel:Organic%20Search,analytics.pagePath:~2F.
  • The legacy "Unique Visitors from Search" widget does not need to be updated, even though the same thing is broken there too.

Implementation Brief

Rename assets/js/modules/analytics/components/dashboard/DashboardUniqueVisitorsWidget.js to assets/js/modules/analytics/components/dashboard/DashboardSearchVisitorsWidget.js

Update references in:

  • stories/module-analytics-components.stories.js
  • assets/js/modules/analytics/index.js

Change title and label in https://github.com/google/site-kit-wp/blob/c85a22563e5a78d0cbe4c53b0f50489eb48a5f97/assets/js/modules/analytics/components/dashboard/DashboardUniqueVisitorsWidget.js#L149 and in https://github.com/google/site-kit-wp/blob/c85a22563e5a78d0cbe4c53b0f50489eb48a5f97/assets/js/modules/analytics/components/dashboard/DashboardUniqueVisitorsWidget.js#L125 to Unique Visitors from Search

Update the commonArgs as both the regular report and sparkline will need to filter for users that only come from organic search, in https://github.com/google/site-kit-wp/blob/c85a22563e5a78d0cbe4c53b0f50489eb48a5f97/assets/js/modules/analytics/components/dashboard/DashboardUniqueVisitorsWidget.js#L63 add these after the date params:

dimensions: ['ga:channelGrouping']
dimensionFilters: { 'ga:channelGrouping': 'Organic Search'}

Also make sure that sparklineArgs also retains ga:date dimension

Update serviceURL from visitors-overview to acquisition-channels https://github.com/google/site-kit-wp/blob/c85a22563e5a78d0cbe4c53b0f50489eb48a5f97/assets/js/modules/analytics/components/dashboard/DashboardUniqueVisitorsWidget.js#L102

Update _r.drilldown param https://github.com/google/site-kit-wp/blob/c85a22563e5a78d0cbe4c53b0f50489eb48a5f97/assets/js/modules/analytics/components/dashboard/DashboardUniqueVisitorsWidget.js#L103 as specified in AC. No need to urlencode params as there is a function that takes care of that (so it will do the " " -> %20 and "/" -> %2F -> ~2F ). For reference the function is located in /assets/js/modules/analytics/util/report-args.js and looking at the tests for it can give an idea of expected inputs and outputs.: https://github.com/google/site-kit-wp/blob/c85a22563e5a78d0cbe4c53b0f50489eb48a5f97/assets/js/modules/analytics/util/report-args.js#L53

Test Coverage

  • Update backstop screenshots as the component will be updated, you may also need to update the storybook stories.

Visual Regression Changes

  • Labels will update on the widget, requiring a new screenshot.

QA Brief

  • Go to the Site Kit dashboard and find the 'Search Funnel' widget
  • The 'Unique Visitors' widget should now be renamed to 'Unique Visitors from Search'
  • It should also be displaying metrics only for users that came from Organic Search (instead of all users).
  • The source link to 'Analytics' under the sparkline should now point to acquisition-channels rather than visitors-overview.

Changelog entry

  • Update Unique Visitors widget to display the actual number of users coming from search

felixarntz avatar Mar 31 '21 17:03 felixarntz

Thanks @ivankruchkoff – a few things to address yet.

  • The IB does not currently address the change to displayed metric itself

    It should display metrics for only users that came from Organic Search instead of all users (i.e. for dimensionName of ga:channelGrouping and dimensionValue of Organic Search).

  • It's important to note that serviceReportURL argument values (e.g. analytics.trafficChannel:Organic%20Search) should not be URL encoded to avoid double encoding
    • This includes / -> ~2F for the page path which is also handled by the selector

aaemnnosttv avatar Apr 07 '21 10:04 aaemnnosttv

Thanks @ivankruchkoff – a few things to address yet.

  • The IB does not currently address the change to displayed metric itself

    It should display metrics for only users that came from Organic Search instead of all users (i.e. for dimensionName of ga:channelGrouping and dimensionValue of Organic Search).

  • It's important to note that serviceReportURL argument values (e.g. analytics.trafficChannel:Organic%20Search) should not be URL encoded to avoid double encoding

    • This includes / -> ~2F for the page path which is also handled by the selector

@aaemnnosttv I've made an update, can you confirm that the common report args are the right place to add dimensionName and dimensionValue.

I also added another label that needs updating.

ivankruchkoff avatar Apr 08 '21 05:04 ivankruchkoff

@ivankruchkoff report selectors don't have arguments for dimensionName or dimensionValue. We need to pass these to the dimensions and dimensionFilters respectively, but it's not a 1-1 change. See the docs for these options here: https://github.com/google/site-kit-wp/blob/e465574ad2be4bfcdca30f744c0dc0be208e17e2/assets/js/modules/analytics/datastore/report.js#L138-L139

I think you also worked on the backend for the dimensionFilters at one point too.

can you confirm that the common report args are the right place to add

Yes it looks like it since these args are shared between reports used for the main data (stat) and for the sparkline chart 👍

aaemnnosttv avatar Apr 08 '21 10:04 aaemnnosttv

@ivankruchkoff report selectors don't have arguments for dimensionName or dimensionValue. We need to pass these to the dimensions and dimensionFilters respectively, but it's not a 1-1 change. See the docs for these options here:

https://github.com/google/site-kit-wp/blob/e465574ad2be4bfcdca30f744c0dc0be208e17e2/assets/js/modules/analytics/datastore/report.js#L138-L139

I think you also worked on the backend for the dimensionFilters at one point too.

can you confirm that the common report args are the right place to add

Yes it looks like it since these args are shared between reports used for the main data (stat) and for the sparkline chart 👍

Updated, and yes git blame certainly points at me :) 2421

ivankruchkoff avatar Apr 12 '21 06:04 ivankruchkoff

LGTM 😄

IB ✅

aaemnnosttv avatar Apr 12 '21 11:04 aaemnnosttv

QA Update: Fail ❌

@johnPhillips three observations:

  1. the organic search in the pie chart is displaying 472 users, where the Unique Visitors from Search' data shows 551 unique visitors. Should these be the same? When I ran the report directly in Analytics, 551 was the result, but would like to check because I wonder if the difference will create confusion?

  2. When I click on the Source: Analytics link it takes me to the visitors-overview report in Analytics, but according to the QAB it should be acquisition-channels

  3. The default period for the report in Analytics is 7 days, but in Site Kit, the period was set to 28 days, is this correct?

image

Verified:

The 'Unique Visitors' widget is now be renamed to 'Unique Visitors from Search' - Screenshot

wpdarren avatar Apr 19 '21 13:04 wpdarren

@wpdarren Thanks for the review.

Something funny might be going on here, I think... This is my local environment - the figures match up:

Screenshot 2021-04-19 at 16 35 38

The source link under 'Unique visitors from search' points at acquisition-channels, and the duration on the report is 28 days 🙈

Is it possible to share a link to the site you used here? Also, I wonder if it is worth checking whether there is some sort of cache issue. Perhaps the code on the site you are looking at needs a refresh? I don't know what your workflow is for QA but perhaps you could try clearing the browser cache, session storage etc.

If the code is up to date then this might require someone with a slightly better understanding than me about analytics reporting to have a little look as well. As far as I could see I implemented the IB correctly. CC @ivankruchkoff I don't know if you can spot any issues with my PR - happy to address them if so 🙏

johnPhillips avatar Apr 19 '21 15:04 johnPhillips

@johnPhillips let me go through my test site and make sure it is not a caching issue.

wpdarren avatar Apr 19 '21 16:04 wpdarren

QA Update: Pass ✅

Verified:

  • The 'Unique Visitors' widget is now be renamed to 'Unique Visitors from Search'
  • The 'Unique Visitors from Search' is displaying metrics only for users that came from Organic Search.
  • The source link to 'Analytics' under the sparkline now points to acquisition-channels rather than visitors-overview.

image

@johnPhillips I figured out the issue with why the data was different (needed to set widgets.dashboard in the tester plugin on my test site)

wpdarren avatar Apr 20 '21 16:04 wpdarren

Approval ❌

There is a problem here related to the source link: It only leads to the filtered view including only "Organic Search" in the single URL view. On the overall dashboard, it still leads to the overall channels view without the "Organic Search" filter like it should.

This is because in https://github.com/google/site-kit-wp/pull/3142/files#diff-05c312086666c0cdc8e39ab72ba4f96e393a1448ace9e0593c2b8618e9c091edR105 the required filter parameter is only added if a single entity URL is present, but it needs to always be added.

@johnPhillips @eugene-manuilov @wpdarren

felixarntz avatar Apr 26 '21 18:04 felixarntz

With the additional fix merged, this works as expected now! ✅

felixarntz avatar Apr 26 '21 19:04 felixarntz