Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sitemap request showing in Statify #185

Closed
Zodiac1978 opened this issue Aug 31, 2020 · 1 comment · Fixed by #186
Closed

Sitemap request showing in Statify #185

Zodiac1978 opened this issue Aug 31, 2020 · 1 comment · Fixed by #186

Comments

@Zodiac1978
Copy link
Member

Zodiac1978 commented Aug 31, 2020

I am running XML Sitemap Generator on my blog which is disabling the new core feature from WordPress 5.5 with a filter:
add_filter( 'wp_sitemaps_enabled', '__return_false' );

See: https://make.wordpress.org/core/2020/07/22/new-xml-sitemaps-functionality-in-wordpress-5-5/

Although there is no sitemap under /wp-sitemaps.xml on my site I have 114 requests tracked in Statify for this address (which results in a 404).

I think we should hide those requests, but unfortunately there is no conditional tag like is_sitemap() but there is a comment with an answer on the official post:

Is there a template function like is_sitemap() or doing_sitemap(). I ask as I have a other filters I running that should not run inside the sitemap.

There currently isn’t, so checking get_query_var( ‘sitemap’ ) is probably the easiest way to do that

See: https://make.wordpress.org/core/2020/07/22/new-xml-sitemaps-functionality-in-wordpress-5-5/#comment-39484

@Zodiac1978 Zodiac1978 added the bug label Aug 31, 2020
@stklcode
Copy link
Contributor

stklcode commented Sep 2, 2020

Confirmed. at least in default mode (no JS).
Unsuprisingly we do not detect the Sitemap call. Even if disabled and a 404 is returned, is_404() results in false for this call. With JS enabled, the 404 is fine.

We should add defined treatment for sitemap calls anyway, i.e. always skip tracking (because it is never possible with JS enabled).

Tested in WP 5.5.1

  • Core Sitemaps enabled
    • Statify in Default mode (no JS)
      • wp-sitemaps.xml delivers XML sitemap
      • Statify tracks sitemap visit
    • Statify in JavaScript mode
      • wp-sitemaps.xml delivers XML sitemap
      • no Statify call
  • Core Sitemaps disabled
    • Statify in Default mode (no JS)
      • wp-sitemaps.xml delivers 404
      • Statify tracks sitemap/404 visit
    • Statify in JavaScript mode
      • wp-sitemaps.xml delivers 404
      • no Statify call

Apparently out tracking hook in the template_redirect phase for non-JS is too early and the sitemap module has not yet been processed, so we don't know if there actually is a sitemap or not. The wp_footer hook for JS is skipped correctly, because is_404() returns true at this point.

@stklcode stklcode added this to the 1.8.1 milestone Sep 2, 2020
stklcode added a commit that referenced this issue Dec 7, 2020
Exclude sitemap and sitemap stylesheet calls with WP 5.5 core sitemaps
from tracking. Including unit tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants