Add date filters for relevant metrics in AdSense dashboard
Feature Description
In the Search Console and Analytics dashboard there is a date filter:

However, this is not present in the AdSense dashboard screen. The "Estimated Earnings" widget doesn't need date filter, but the other two statistics on this screen would benefit from it.
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
- There should be a date picker on top of the AdSense module page, similar like it is on e.g. the Analytics module page.
- The "Estimated Earnings" widget should be removed entirely.
- The first "Performance over previous 28 days" should be updated:
- Title should change to "Performance over the last 28 days" (suffix should be based on current date range like in e.g. Analytics module page), for consistency with date picker and similar headings in e.g. Analytics module page.
- There should be two additional columns in the widget:
- The "Earnings" value for the current period should be the first column, before "Page RPM".
- The "Page CTR" value for the current period should be the fourth column, after "Impressions" (the AdSense metric is called
PAGE_VIEWS_CTR).
- The values (i.e. the respective queries) should be based on the currently selected date range.
- "Advanced Settings" should change to "See full stats in AdSense".
- The second "Performance over previous 28 days" should be updated:
- Title should change to "Performance by page over the last 28 days" (suffix should be based on current date range like in e.g. Analytics module page).
- The values (i.e. the respective queries) should be based on the currently selected date range.
- "Advanced Settings" should change to "See full stats in AdSense".
Implementation Brief
- In
assets/js/modules/adsense/index.legacy.jsadd thegooglesitekit.showDateRangeSelector-${ slug }to return true to display theDateRangeSelectorcomponent in the AdSense page. - Wrap the
AdSenseDashboardWidgetwith thewithSelectHOC fromDatathat adds thedateRangeprop using thegetDateRangeselector fromcore/user - import the
getCurrentDateRangeto use for displaying the date range in other components. - Remove the
<Layout />component fromAdSenseDashboardWidgetcomponent that represents the Estimated earnings section. - Update the titles for each remaining
Layoutcomponents to reflect date range as per the AC. - Refactor the
AdSensePerformanceWidgetto be a functional component. - Refactor the
withDatasettings inAdSensePerformanceWidgetto use thegetReportselector from themodules/adsensedatastore passingmetrics: [ 'EARNINGS', 'PAGE_VIEWS_RPM', 'IMPRESSIONS', 'PAGE_VIEWS_CTR' ],to retrieve thePAGE_VIEWS_CTRdata point - Add the new Earnings and Page CTR columns to the
AdSensePerformanceWidget - Ensure that all values are being updated to reflect the selected date range.
- Update all Advanced Settings text to See fill stats in AdSense
- Finish and merge #1971
QA Brief
- The date picker should be available on the AdSense dashboard page
- The Estimated Earnings module should no longer exist.
- The title of the first modules should read
Performance over the last XX dayswhere the XX is the currently selected date range. - The first module should have 4 sections:
- Earnings, Page RPM, Impressions, and Page CTA
- They should all update their values based on changes to the date range selector.
- The title of the second modules should read
Performance by page over the last XX dayswhere the XX is the currently selected date range. - The data for the second module should update when the date range is changed.
- External link for both modules should say
See full stats in AdSensewith the external link icon.
Changelog entry
- Make AdSense module page UI more consistent with other modules, allowing to filter information by date instead of showing at-a-glance information for different date periods.
Hi Lily,
As you said, could we add a date picker to the 2nd & 3rd charts in the AdSense dashboard screen. Best to match the way it is implemented in Search Console, Analytics & other screens. The titles of the 2nd & 3rd screens will need to change as they currently include "over previous 28 days".
The date picker should include "today" as well as the same options as the other products: 7, 14, 28, 90 days.
Hey @OisinOConnor, is there a more descriptive name you'd suggest for the section called "Other metrics"?
@OisinOConnor Could you provide an update on this?
Possibly:
- Performance metrics
- Site performance
@marrrmarrr Updated ACs based on our conversation earlier. I also included a note to change the "Advanced Settings" text to "See full stats in AdSense", which makes more sense here and is in line with what we display in the same place for Analytics.
I opened #1921 for the separate follow-up task to introduce a graph for these metrics over the period to this screen like we said earlier.
Does this mean all you guys and these notices...that you are working on my site?
-----Original Message----- From: Felix Arntz [email protected] To: google/site-kit-wp [email protected] Cc: Subscribed [email protected] Sent: Mon, Aug 17, 2020 11:12 am Subject: Re: [google/site-kit-wp] Add date filters for relevant metrics in AdSense dashboard (#317)
@marrrmarrr Updated ACs based on our conversation earlier. I also included a note to change the "Advanced Settings" text to "See full stats in AdSense", which makes more sense here and is in line with what we display in the same place for Analytics.I opened #1921 for the separate follow-up task to introduce a graph for these metrics over the period to this screen like we said earlier.— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.
@ryanwelcher IB mostly looks good, just one thing:
Add
PAGE_VIEWS_CTRto the array of metrics inincludes/Modules/AdSense.php
These metrics being set in PHP is now somewhat legacy, that datapoint as of #1776 supports requesting specific metrics from the client. So rather than altering that server-side default (which only exists for backward-compatibility), let's modify the client-side request to include a metrics field with all four metrics.
IB ✅
Tested
Installed, activated and setup latest develop SK. Activated Adsense module and checked the following:
- Confirmed estimated earnings is no longer on the Adsense Dashboard
- 4 items are displayed (Earnings, Page RPM, Impressions, and Page CTR) in the performance box
- 'Performance over the last XX days' title exists and functions properly
- External 'See full stats in AdSense' link functions properly
- Confirmed mobile, and smaller size window views function properly
Items to note:
The green check for 'Adsense is connected' is not clearing itself

When there's no ad impressions for 7 days, the date filter becomes broken unless the user refreshes the page:

Sending back to @ryanwelcher for adjustments
Items to note: The green check for 'Adsense is connected' is not clearing itself
@cole10up I believe this is expected behavior.
@cole10up @felixarntz - @aaemnnosttv and I were able to reproduce the zero data issue and it's related to withData. @aaemnnosttv is going to open a ticket to address it separately.
It turns out the issue was local to the AdSenseDashboardWidget component which tracks zeroData separately from withData. It's been fixed in #2224 👍
@cole10up ready for another pass 👍
Retested
Was able to confirm 0 data doesn't corrupt the date sort.

Noticed the Page Performance box, when loading shows multiple rows prior to finishing the load. Not a show stopper but something to note.
Passed QA ✅
During smoke testing with the latest release I am seeing the following
On hellogoodbye.today when on the Adsense dashboard, when I flip from 28 days to 90 days, there is data according to the full stats in Adsense but I'm seeing what is looking like actual data available for a millisecond then the 'No ad impressions yet' message is shown. See below. Flipping to 90 days you see a quick flash of the actual metrics

Checking Adsense statistics, I see impressions past 28 days:

Sending back to Execution for adjustments as 90 days should display data when available.
@ryanwelcher @aaemnnosttv Let's try to find the reason for this one early on Monday. It's not a highly critical problem I think, but it appears to be a regression from this one, so it should be addressed in a timely manner.
Depending on whether the fix is simple enough, we can squeeze it into this release - otherwise let's open a follow-up issue and mark it for the 1.20.0 release.
@felixarntz @ryanwelcher It has to do with a change to the isDataZeroAdSense function; will open a PR against master for this now.
@felixarntz The PR is opened for inclusion in the release now. The problem @cole10up found was that the component would render a zero data state if the previous range had no data.
Using Cole's data which is able to reproduce the behavior above, I can now see the 90 day range (note the relative change indicators and values are not shown due to lack of data).

Retested
Installed the latest zip, activated and setup SK. Activated Adsense and confirmed the fix:

Passed QA ✅