Skip to content

WOOA7S-2294: Premium Analytics: Add Build URL to empty UTM widget - #53458

Merged
Nikschavan merged 6 commits into
trunkfrom
wooa7s-2294-utm-empty-builder
Oct 13, 2026
Merged

Nikschavan merged 6 commits into
trunkfrom
wooa7s-2294-utm-empty-builder

Conversation

@Nikschavan

@Nikschavan Nikschavan commented Oct 12, 2026 •

Copy link
Copy Markdown
Member

Fixes WOOA7S-2294

Proposed changes

When Top UTM has no visits in the selected period, I offer Build URL in the empty state. The action opens a URL builder so someone can create a tagged link without leaving the dashboard. The existing View all link remains available.

I used the shared empty-state action and Gutenberg dialog components. The builder preserves existing query parameters and URL fragments. The empty-state text refers to visits in the selected period because the stats response cannot tell whether someone has created a tracked URL.

The builder only accepts an http or https destination, and it needs at least one UTM value before Copy to clipboard is enabled. A destination without a protocol, such as example.com, gets an error under the field once the field loses focus, because the Stats v1 builder accepted that input and people will type it. A UTM value the destination already carries is replaced by the value from its field, and removed when that field is left empty.

Copy to clipboard sits in the dialog footer, so it stays visible when the content scrolls on a small screen. The prototype has it as an outline button under the URL box. It uses useCopyToClipboard from @wordpress/compose, which falls back to execCommand on HTTP sites where navigator.clipboard does not exist. After a successful copy the dialog closes and a snackbar confirms it, because a snackbar renders underneath an open @wordpress/ui dialog and would not be seen. The hook has no failure callback, so a failed copy shows nothing. I am still checking the footer position and the close-on-copy behaviour with design, so both may change.

Prototype This PR
Build URL dialog in the prototype, with an outline Copy to clipboard button under the URL box Build URL dialog in this PR, with a solid Copy to clipboard button in the dialog footer
Outline Copy to clipboard button under the URL box Solid Copy to clipboard button in the dialog footer

Copying closes the dialog and shows the snackbar on the dashboard:

utm-builder-copy-closes-dialog.mp4

Related product discussion/links

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

No.

Testing instructions

  • Sync this branch to a Jurassic Ninja site with Premium Analytics, then open Stats → Traffic.
  • Select a period with no UTM visits. In Top UTM, open Build URL and enter a destination URL plus campaign, source, and medium values. Check the preview.
  • Select Copy to clipboard. The dialog should close, a "Copied URL to clipboard." snackbar should show, and the clipboard should hold the URL from the preview.
  • Open Build URL again, enter example.com as the destination and move to the next field. An error under the field should ask for a full URL, and Copy to clipboard should stay disabled.
  • Check that View all remains available. Select a period with UTM visits and confirm that the widget shows rows instead of the Build URL action.

I tested the copy flow on my local site in Chrome. I did not test a failed copy or an HTTP site.

@Nikschavan Nikschavan added Enhancement Changes to an existing feature — removing, adding, or changing parts of it [Status] In Progress labels Oct 12, 2026
@Nikschavan Nikschavan self-assigned this Oct 12, 2026
@github-actions

github-actions Bot commented Oct 12, 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), and enable the wooa7s-2294-utm-empty-builder branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack wooa7s-2294-utm-empty-builder

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 labels Oct 12, 2026
@github-actions

github-actions Bot commented Oct 12, 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:

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.


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 Oct 12, 2026 •

Copy link
Copy Markdown

Code Coverage Summary

Coverage changed in 1 file.

File Coverage Δ% Δ Uncovered
projects/packages/premium-analytics/widgets/utm-insights/render.tsx 34/35 (97.14%) 0.27% 0 💚

1 file is newly checked for coverage.

File Coverage
projects/packages/premium-analytics/widgets/utm-insights/utm-url-builder-dialog.tsx 45/45 (100.00%) 💚

Full summary · PHP report · JS report

@Nikschavan
Nikschavan marked this pull request as ready for review October 12, 2026 13:16
@Nikschavan
Nikschavan requested a review from a team as a code owner October 12, 2026 13:16
Copilot AI balanced review requested due to automatic review settings October 12, 2026 13:16
@Nikschavan Nikschavan added [Status] Needs Review This PR is ready for review. and removed [Status] In Progress labels Oct 12, 2026

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@chihsuan chihsuan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice work on the URL builder! @Nikschavan I tested the empty state, validation and copy flow, and they work nicely. 👍 I left a few inline notes, mainly around closing the dialog on copy.

@Nikschavan
Nikschavan force-pushed the wooa7s-2292-widget-empty-actions branch from 32d6f35 to e1d7ab7 Compare October 13, 2026 05:07
@Nikschavan
Nikschavan force-pushed the wooa7s-2294-utm-empty-builder branch from 0c335c3 to 473651a Compare October 13, 2026 05:09
chihsuan
chihsuan previously approved these changes Oct 13, 2026

@chihsuan chihsuan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the updates! @Nikschavan The copy flow and validation work nicely now, approving. 👍 I left a few non-blocking inline notes.

Base automatically changed from wooa7s-2292-widget-empty-actions to trunk October 13, 2026 06:45
@Nikschavan
Nikschavan dismissed chihsuan’s stale review October 13, 2026 06:45

The base branch was changed.

Use InputControl from @wordpress/ui for the builder fields and tell the user when the destination lacks an http(s) protocol.

Close the dialog after a successful copy so the snackbar is visible, since a snackbar renders under an open dialog. A failed copy keeps the dialog open and shows an error notice inside it.
…tion

Copy goes through useCopyToClipboard, so it also works on HTTP sites where navigator.clipboard is undefined. The hook has no failure callback, so the failed-copy notice is removed.

The destination error uses ValidatedInputControl and shows after the field loses focus, not on the first keystroke. Headings and paragraphs in the dialog use Text, as the rest of the package does.
Closing the dialog on copy cleared the form, so a second URL for the same campaign meant typing every field again. The dialog now stays open and the button confirms the copy for four seconds, or until a field changes, so it never confirms a URL that was not copied. The snackbar and its notices dispatch are removed.

The Build URL test asserted on the widget while the open dialog hid it from role queries, so it passed with any empty state. It now closes the dialog first. The widget declares @wordpress/compose, which the dialog imports.
@Nikschavan
Nikschavan force-pushed the wooa7s-2294-utm-empty-builder branch from 28ee048 to 65cfa76 Compare October 13, 2026 06:53
With UTM fields filled and no valid destination, the preview still asked for campaign parameters, so nothing pointed at the field that was missing. It now asks for the destination URL in that case.

The preview wraps with overflow-wrap, because break-all also split the placeholder sentence in the middle of a word on a narrow screen.
The message said the same as the generic empty state, so nothing explained what Build URL was for. It now tells the reader to build a URL to start tracking a campaign.
@Nikschavan
Nikschavan requested a review from chihsuan October 13, 2026 07:39

@chihsuan chihsuan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you! @Nikschavan LGTM 🚢

@Nikschavan
Nikschavan merged commit efc60a5 into trunk Oct 13, 2026
95 checks passed
@Nikschavan
Nikschavan deleted the wooa7s-2294-utm-empty-builder branch October 13, 2026 10:46
@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 Oct 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Enhancement Changes to an existing feature — removing, adding, or changing parts of it [JS Package] Premium Analytics Sdk [Package] Premium Analytics [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Plugin] Premium Analytics RNA [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.

3 participants