Skip to content

Comments

Stats: Fix tracking of search terms, tags & parsing of tax queries#43879

Merged
sotirispl merged 2 commits intotrunkfrom
fix/search-stats-missing-fields
Jun 12, 2025
Merged

Stats: Fix tracking of search terms, tags & parsing of tax queries#43879
sotirispl merged 2 commits intotrunkfrom
fix/search-stats-missing-fields

Conversation

@sotirispl
Copy link
Contributor

@sotirispl sotirispl commented Jun 10, 2025

Fixes

  • Cases where the search term can't be tracked by the WP_Query array.
  • Cases where the tag slug is not used in the WP_Query when visiting a tag's archive page.
  • Fixes an invalid check on taxonomies' slugs when collecting the search filters for Jetpack Stats.

Proposed changes:

  • Handle relevant warnings by checking both query and query_vars arrays.
  • Removed a check on the taxonomy's slug field when building the relevant taxonomies search filters.

Other information:

  • Have you written new tests for your changes, if applicable?
  • Have you checked the E2E test CI results, and verified that your changes do not break them?
  • Have you tested your changes on WordPress.com, if applicable (if so, you'll see a generated comment below with a script to run)?

Jetpack product discussion

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

Testing instructions:

  • At your test site, set up a tag and a custom taxonomy. Add posts to them.
  • Add Jetpack Search but disable the Instant Search toggle and install a theme that supports the search widget (e.g. Twenty Twenty-One).
  • Log out from your admin account
  • Visit your tag's page and verify that the pixel request contains the expected payload.
  • Make a search request using the s URL parameter and another that makes a taxonomy query too (e.g. ?s=searchterm&testtax=taxonomy) and verify that both pixel requests contain the expected payload.
  • Try different searches with different combinations of search terms, taxonomies, and tags.

@github-actions
Copy link
Contributor

github-actions bot commented Jun 10, 2025

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 fix/search-stats-missing-fields branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack fix/search-stats-missing-fields
bin/jetpack-downloader test jetpack-mu-wpcom-plugin fix/search-stats-missing-fields

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
Copy link
Contributor

github-actions bot commented Jun 10, 2025

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 a "[Type]" label (Bug, Enhancement, Janitorial, Task).
  • ✅ 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!

@github-actions github-actions bot added the [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. label Jun 10, 2025
@sotirispl sotirispl changed the title Fix/search stats missing fields Stats: Fix tracking of search terms, tags & parsing of tax queries Jun 10, 2025
@jp-launch-control
Copy link

jp-launch-control bot commented Jun 10, 2025

Code Coverage Summary

Coverage changed in 1 file.

File Coverage Δ% Δ Uncovered
projects/packages/stats/src/class-tracking-pixel.php 89/119 (74.79%) 0.21% 0 💚

Full summary · PHP report · JS report

@sotirispl sotirispl requested review from gibrown and myhro June 10, 2025 14:14
Copy link
Contributor

@myhro myhro left a comment

Choose a reason for hiding this comment

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

LGTM. ✅

Tried the following cases:

Search

v: ext
blog: 236297789
post: 0
tz: 0
srv: jetpack.myhrowp.com
arch_search: lorem
arch_filters: posts_per_page=10&paged=1&orderby=&order=DESC
arch_results: 1
j: 1:14.8-a.3
host: jetpack.myhrowp.com
ref: https://jetpack.myhrowp.com/
fcp: 301
rand: 0.17667270060733986

Category

v: ext
blog: 236297789
post: 0
tz: 0
srv: jetpack.myhrowp.com
arch_cat: writings
arch_results: 2
j: 1:14.8-a.3
host: jetpack.myhrowp.com
ref: https://jetpack.myhrowp.com/2025/03/12/lorem-ipsum/
fcp: 279
rand: 0.8811503500882137

Tag

v: ext
blog: 245393704
post: 0
tz: 0
srv: remaining-crane-equinox.jurassic.ninja
arch_tag: tip
arch_results: 1
hp: atomic
ac: 32
amp: 0
j: 1:14.8-a.4
host: remaining-crane-equinox.jurassic.ninja
ref
rand: 0.25471570133750665

Taxonomy

v: ext
blog: 245393704
post: 0
tz: 0
srv: remaining-crane-equinox.jurassic.ninja
arch_tax_help: intro-101
arch_results: 1
hp: atomic
ac: 32
amp: 0
j: 1:14.8-a.4
host: remaining-crane-equinox.jurassic.ninja
ref
rand: 0.08679834836917522

@myhro myhro added Enhancement Changes to an existing feature — removing, adding, or changing parts of it [Status] Needs Review This PR is ready for review. and removed [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. labels Jun 11, 2025
@myhro
Copy link
Contributor

myhro commented Jun 11, 2025

@sotirispl I'm trying to fix the labels based on GitHub Actions bot suggestions:

image

I've left the Needs Review, in case you are still waiting for Greg's feedback, but we can swap it to Ready to Merge if preferable.

@sotirispl sotirispl force-pushed the fix/search-stats-missing-fields branch from aede6a9 to 35a90ef Compare June 12, 2025 09:39
@sotirispl sotirispl merged commit 69868e8 into trunk Jun 12, 2025
69 checks passed
@sotirispl sotirispl deleted the fix/search-stats-missing-fields branch June 12, 2025 10:38
@github-actions github-actions bot removed the [Status] Needs Review This PR is ready for review. label Jun 12, 2025
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 [Package] Stats Data

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants