Skip to content

Premium Analytics: Leave Average CPM empty when no ads were served - #52690

Merged
chihsuan merged 3 commits into
trunkfrom
change/uni-805-cpm-no-impressions
Sep 24, 2026
Merged

chihsuan merged 3 commits into
trunkfrom
change/uni-805-cpm-no-impressions

Conversation

@chihsuan

@chihsuan chihsuan commented Sep 23, 2026 •

Copy link
Copy Markdown
Member

Fixes UNI-805

Proposed changes

The Average CPM tab in the Ads chart read a day with no ads served as a measured $0.00 CPM. Today's bucket stays empty until the nightly WordAds run, so every range ending today dropped the line to $0.00, and a range with no ads at all showed a $0.00 headline.

  • Leave a day, week or month with no ads served as a gap in the Average CPM line and bar chart, with a "No data for Average CPM" tooltip.
  • Keep the CPM row in the Ads Served and Revenue tooltips on those days, reading "No data for Average CPM" instead of $0.00.
  • Show a dash for Average CPM when the whole range served no ads, with "No ads were served in this period." in place of the chart.

WordPress.com writes a CPM of 0 when nothing was served, as a divide-by-zero guard, so the data layer now marks it missing; the shared chart helpers in packages/premium-analytics/packages/widgets-toolkit keep it missing instead of turning it back into 0.

Related product discussion/links

Does this pull request change what data or activity we track or use?

No.

Testing instructions

Setup

  1. Check out this branch and build Premium Analytics.
  2. Use a site with WordAds active, or a fixture whose last wordads/stats row (today) is [ date, 0, 0, 0 ], as WordPress.com returns before the nightly run.

Average CPM tab

  1. Open Stats › Ads on Last 30 days and select Average CPM. Confirm the line ends the day before today.
  2. Hover today. Confirm the tooltip reads "No data for Average CPM".
  3. Switch to bar mode. Confirm today has no bar and the same tooltip.

Ads Served tab

  1. Hover today. Confirm the tooltip still lists three rows, with "No data for Average CPM".

A range with no ads served

  1. Serve zero impressions for every day, then select Average CPM. Confirm a dash and "No ads were served in this period."
Before After
Before: the Average CPM line drops to $0.00 on today's empty bucket After: the line stops at yesterday and today reads No data for Average CPM

Before is the widget's Storybook story with the same empty bucket. Only the last day should differ; the value axis is not part of this change.

Ads Served tab keeps the CPM row as No data

A range with no ads served: dash and reason on the Average CPM tab

@github-actions

github-actions Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WoA dev site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin (Jetpack or WordPress.com Site Helper), and enable the change/uni-805-cpm-no-impressions branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack change/uni-805-cpm-no-impressions
bin/jetpack-downloader test jetpack-mu-wpcom-plugin change/uni-805-cpm-no-impressions

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

@github-actions github-actions Bot added [Package] Premium Analytics [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Plugin] Premium Analytics [Plugin] Wpcomsh labels Sep 23, 2026
@github-actions

github-actions Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, reach out in #jetpack-developers for guidance!


Jetpack plugin:

The Jetpack plugin has different release cadences depending on the platform:

  • WordPress.com Simple releases happen as soon as you deploy your changes after merging this PR (PCYsg-Jjm-p2).
  • WoA releases happen weekly.
  • Releases to self-hosted sites happen monthly:
    • Scheduled release: October 6, 2026

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.


Wpcomsh plugin:

  • Next scheduled release: Atomic deploys happen twice daily on weekdays (p9o2xV-2EN-p2)

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.


Premium Analytics plugin:

No scheduled milestone found for this plugin.

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.

@jp-launch-control

jp-launch-control Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

Code Coverage Summary

Coverage changed in 3 files.

File Coverage Δ% Δ Uncovered
projects/packages/premium-analytics/packages/data/src/processing/stats/wordads.ts 17/17 (100.00%) 0.00% 0 💚
projects/packages/premium-analytics/packages/widgets-toolkit/src/helpers/build-metric-tab.ts 9/9 (100.00%) 0.00% 0 💚
projects/packages/premium-analytics/widgets/wordads-chart-tabs/use-wordads-chart.ts 6/6 (100.00%) 0.00% 0 💚

Full summary · PHP report · JS report

Base automatically changed from wooa7s-2181-premium-analytics-stop-turning-a-missing-subscriber-count to trunk September 23, 2026 22:04
@github-actions github-actions Bot added the Docs label Sep 23, 2026
@chihsuan
chihsuan force-pushed the change/uni-805-cpm-no-impressions branch from 5f00bb1 to 473163b Compare September 24, 2026 02:05
@chihsuan
chihsuan force-pushed the change/uni-805-cpm-no-impressions branch from 473163b to 599bc9d Compare September 24, 2026 03:16
@chihsuan
chihsuan marked this pull request as ready for review September 24, 2026 03:20
@chihsuan
chihsuan requested a review from a team as a code owner September 24, 2026 03:20
@chihsuan chihsuan added [Status] Needs Review This PR is ready for review. and removed [Status] In Progress labels Sep 24, 2026

@dognose24 dognose24 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested the branch: jp test js packages/premium-analytics (3771 tests) and tsgo --noEmit both pass, and I read the normalizer, the two shared helpers and the hook. The change is right: a CPM of 0 with no impressions is a guard value, not a reading, and nulling it at the data layer is the one place every consumer benefits from.

Two things I checked because the helpers are shared:

  • toPoints now keeps null for every metric tab, not just CPM. Today only the WordAds normalizer emits null into a data point; the time-series normalizer behind the Traffic chart never does, so this changes nothing there. Worth remembering when a future normalizer starts returning null.
  • appendTooltipExtras now lists a point whose value is null, and #52523's tooltip reads that as "No data". Good.

One question, not a blocker: when the whole range served no ads, the CPM tab is unavailable, and MetricTabsChart leaves unavailable metrics out of the extras, so the Ads Served and Revenue tooltips drop the CPM row entirely rather than reading "No data for Average CPM" as they do on a single empty day. Intentional? It reads fine either way; just noting the two cases differ.

Nit: the description still says "Retarget to trunk once it merges", but #52523 is in and the base is already trunk.

@chihsuan

Copy link
Copy Markdown
Member Author

Good question. That's the existing unavailable behavior, already dropping a metric from other tabs' tooltips before this PR. The single-day gap uses the new null path instead, so the two read differently by design.

@chihsuan
chihsuan merged commit 2c33ad7 into trunk Sep 24, 2026
83 of 84 checks passed
@chihsuan
chihsuan deleted the change/uni-805-cpm-no-impressions branch September 24, 2026 05:16
@chihsuan

Copy link
Copy Markdown
Member Author

Good catch, updated the description to drop that line since #52523 already merged.

@github-actions github-actions Bot added [Status] UI Changes Add this to PRs that change the UI so documentation can be updated. and removed [Status] Needs Review This PR is ready for review. labels Sep 24, 2026
@dognose24

Copy link
Copy Markdown
Contributor

Also ran it on the local Docker site with a mocked wordads/stats whose today bucket is [ date, 0, 0, 0 ]: the Average CPM line stops at yesterday with the x axis still reaching today, Ads Served still drops to 0 there, and with every bucket zeroed the CPM tab reads a dash with "No ads were served in this period." One note for anyone testing locally: with a stale js-packages/charts dist the CPM tab shows Invalid data instead of the gap, since the gap support is #52580 in charts; jp build js-packages/charts first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Docs [Package] Premium Analytics [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Plugin] Premium Analytics [Plugin] Wpcomsh [Status] UI Changes Add this to PRs that change the UI so documentation can be updated.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants