Show change values in AdSense summary widget
Originally reported as part of #656: In the AdSense summary widget, only the "Total Earnings" value currently shows up with a change percentage. The "RPM" (or "Page RPM" as of #656) and "Ad Impressions" values should also have a change value.
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
- The AdSense summary widget on the dashboard should be updated as follows (only for the refactored version, i.e.
DashboardSummaryWidget):- The change value displayed for the monetary earnings value should be the change value compared to the previous period, rather than the value of "today's" earnings.
- There should be a change value displayed for the "RPM" / "Page RPM" metric: It should be the absolute change from the previous period value and should be formatted with the currency (similar to how it is for the "Total Earnings" change value, i.e. do not use percentage like we mostly do otherwise).
- There should be a change value displayed for the "Ad Impressions" metric: Similar to the above, it should be the absolute change from the previous period value and it should be formatted without any unit (i.e. just the absolute difference, not a percentage).
Implementation Brief
- Using
assets/js/modules/adsense/components/dashboard/DashboardSummaryWidget.js,- Get the
compareStartDateandcomparedEndDatesto be used for querying the data for the previous period by passingcompare: trueto thegetDateRangeDatesselector. - Get a report for the previous period with the same metrics as
periodArgsand setstartDateandendDatetocompareStartDateandcompareEndDaterespectively. - ~~Use the
calculateChangefunction fromassets/js/util/index.js, to calculate the changed values between the current period and previous period reports data and pass the value as thechangeprop of eachDataBlockcomponent.~~ - The
changeDataUnitprop should be the currency for the first 2DataBlockcomponents and metric for the last one.
- Get the
Test Coverage
- N/A
Visual Regression Changes
- Visual changes to the
DashboardSummaryWidgetcomponent.
QA Brief
- Make sure you have the
widgets.dashboardfeature enabled, and have Analytics and AdSense set up. - Go to the Site Kit dashboard and scroll down to the
DashboardSummaryWidget. This is the one under theEarningsheading that sits on the left hand side, with the spark lines. - All three values should now display a 'change' (i.e. with up/ down arrow) if the values have changed.
- Page RPM and Earnings should show 'change' with currency units (e.g. Dollar sign).
Changelog entry
- Update AdSense summary dashboard widget to show change values for each metric relative to the previous period.
@felixarntz @aaemnnosttv I had a look at the current implementation for the "Total Earnings" changed values. Turns out that we are not showing the changed value compared to the previous period, but showing the value for the current day, which is something I think is misleading unless it was intentional. I've added the IB where instead of showing the value of the current day as changed value, we calculate the it based on the reports from the current and previous periods.
Let me know if am missing anything. Thanks!
@asvinb I think that was intentional, but I agree that it isn't clear since it isn't labelled as such anywhere. Not sure if there is an easy fix for that which fits in the current design. Maybe just prefixing it with Today: {earnings}
The change arrow there is also a bit redundant since it would never be negative (I hope? 😆 )
Thoughts @felixarntz ?
Good catch @asvinb! I think we should change this then to also refer to the previous period, like we have elsewhere in the dashboard. Daily values can be still found in the AdSense module page. I've added a point for this in the ACs.
Thanks @felixarntz . @aaemnnosttv Can you review the IB? thanks!
@aaemnnosttv One more follow-up response from me:
The change arrow there is also a bit redundant since it would never be negative
Makes sense. However I think we should keep this for consistency for now; let's revisit that separately at some point.
IB ✅
Regarding the estimate, it can probably fit in 3 but I feel like we should give it a little more to be on the safe side; bumping to 7.
@asvinb just regarding this:
The changeDataUnit prop should be the currency for the first 2 DataBlock components and metric for the last one
Aren't the values returned by calculateChange percentages?
I will just do the absolute change by subtracting one from the other 👍
Aren't the values returned by
calculateChangepercentages?I will just do the absolute change by subtracting one from the other 👍
@johnPhillips yes you're right, we want absolute values, as noted in the ACS. Thanks for pointing that out!
@johnPhillips would you please add a QA Brief?
QA Update: Pass ✅
Verified:
- All three values now display a 'change' (i.e. with up/ down arrow) if the values have changed.
- Page RPM and Earnings show 'change' with currency units (e.g. Euro).

Pulling this back for a quick follow up as there is now a prop type warning in the console related to a change I made.

Edit: wrong component shown above the devtools, but correct warning.
QA ✅
Prop type warning no longer shows
