Support » Plugin: The SEO Framework » How to verify sitemap ping to Google

  • Resolved Mak

    (@makolyte)


    I have the sitemap setting turned on where it pings Google and Bing. When does it ping? How can I verify that the ping happened and was successful?

    I was trying to find a log somewhere on the server that verified that it ran, but I simply could not find anything.

    Any help would be appreciated.

    Thanks,
    makolyte

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Sybre Waaijer

    (@cybr)

    Hello!

    I also faced this issue when I developed it. Ultimately, I turned on logging within the specific functions before I could trust the code.

    TSF pings at most once per hour. It pings whenever the sitemap’s cache is forcefully cleared, which happens after you: change permalink settings, save SEO settings, or update/publish any post or page.

    When you use cronjobs for pinging, it’ll run at least 30 seconds after the sitemap is deleted. Then, it’ll ping the next time WordPress’s cron is ready. When this happens exactly varies per site.

    When you do not use cronjobs for pinging, then the pinging happens in the same request the sitemap’s cache’s cleared.

    You can check in with Google Search Console and Bing Webmasters, they should tell you when they last read/crawled your sitemap.

    If you want to check this on your site, here’s some info:

    1. We use wp_safe_remote_get(). E.g. wp_safe_remote_get( 'https://www.google.com/ping?sitemap=https%3A%2F%2Fexample.com%2Fsitemap.xml', [ 'timeout' => 3 ] ).
    2. On successful remote GET, filter http_response is invoked.

    So, this filter should help you log the request made from your site via WordPress:

    add_filter( 'http_response', function( $response = [], $parsed_args = [], $url = '' ) {
    	error_log( print_r( $url, true ) );
    	return $response;
    }, 10, 3 );

    Action http_api_debug also runs a few times during the request. So, you can hook into that to take and log information.

    Lastly, the_seo_framework_ping_search_engines fires right after TSF is done pinging. So, you can also use that hook to assert whether it runs.

    I think I covered everything here. Let me know if you require further assistance 🙂 Cheers!

    Thank you for the great information. I checked GSC and Bing and can see they got the updated sitemap today after I published a new post.

    I’ll definitely save the info about how to debug / log it. That’ll definitely come in handy if I notice GSC / Bing are out of date.

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.