Update popularity listing on main dashboard
Query by clicks, add a column with clicks data (keep impressions too) and order them by clicks.
@ThierryA @felixarntz I think we need to discuss this one a bit more but spinning up the ticket to make sure it doesn't get forgotten.
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
- The Popularity widget table on the Site Kit dashboard shows a Clicks column, on the left side of the Impressions column.
- Keywords in the Popularity widget table are sorted by clicks, descending.
Implementation brief
- Remove Search Console datapoint
search-keywords-sort-by-impressions. - In the
casefor the remaining datapoints, remove everything but https://github.com/google/site-kit-wp/blob/develop/includes/Modules/Search_Console.php#L496 (no longer manually sort by impressions). This is okay to do because the other datapoints thansearch-keywordswere accidentally changed to also be sorted by impressions and can easily be changed back to be sorted by clicks (default) without user-facing effects.sc-site-analyticsis only called for dashboard areas where sorting is irrelevant for how the data is displayed (data block with only totals, line chart).page-analyticsis only called in one place, where it's used for a data block with only totals. Actually that datapoint appears to be doing exactly the same assc-site-analytics, so I'd suggest removing it entirely.index-statusis not used at all, but let's not remove it for now - we can revisit that.
- Use
search-keywords-sortinstead ofsearch-keywords-sort-by-impressionsin https://github.com/google/site-kit-wp/blob/develop/assets/js/modules/search-console/dashboard/dashboard-widget-popular-keyword-table.js#L111. - Add a "Clicks" column below https://github.com/google/site-kit-wp/blob/develop/assets/js/modules/search-console/dashboard/dashboard-widget-popular-keyword-table.js#L66, using the existing definition from https://github.com/google/site-kit-wp/blob/develop/assets/js/modules/search-console/dashboard/dashboard-widget-keyword-table.js#L42 (which is used on Search Console module page).
- For reference, https://developers.google.com/webmaster-tools/search-console-api-original/v3/searchanalytics/query (results are always sorted by Clicks, which cannot be adjusted).
Changelog entry
- Show Clicks in the plugin dashboard's Popularity listings and sort the table by them.
Implementation brief review: since Search Console API results sorted by click count descending, there isn't need to query more rows and hack the ordering which we are currently doing. We can get rid of the current hack, render a clicks column and simply query the top 10 results.
@adamsilverstein Do you happen to have any background on why page-analytics exists? It appears to do exactly the same as sc-site-analytics. Same about index-status, it doesn't appear to be used at all? Was it at some point, what was this datapoint meant for?
As you mentioned, page-analytics and sc-site-analytics are currently duplicates, I agree we can safely remove one now.
I did a little git spelunking and found that originally these were two separate similar but distinct data points - one for site wide data and one for page URL specific data:

QA ✅
This overall LGTM. Will only note that when all clicks are 0 it looks slightly weird, but is technically correct. We can consider an alternative display down the road if users get confused.