Hi,
Google Search Console API is not giving any Sitemaps Details for a Domain property siteUrl.
Like : sc-domain:example.com
We can get Sites and Performance data for a Domain property siteUrl, but issue with Sitemaps.
Thanks,
Hi @chiragvels, can you share a code snippet please?
Hi @jdpedrie ,
My code snippet
$client = new Google_Client();
$client->setClientId($client_id);
$client->setClientSecret($client_secret);
$client->setRedirectUri($redirect_uri);
$webmastersService = new Google_Service_Webmasters($client);
$sitemaps = $webmastersService->sitemaps;
$totalsitemaps = $sitemaps->listSitemaps($url); //sc-domain:example.com
$siteMaps = $totalsitemaps->getSitemap();
Thanks,
Hi @chiragvels,
I'm not seeing any issues fetching sitemaps. I tried running your code snippet with a domain I own and it worked fine. The API documentation states that the URL should include the protocol; Could you be providing an invalid URI?
Hi @jdpedrie ,
I was also getting sitemaps perfectly for regular domains like http://www.example.com/.
But my question is Google Search Console API is not giving any Sitemaps Details for a Domain property siteUrl.
Domain property siteUrl is URIs like sc-domain:example.com which was introduced recently.
Google Search Console API is not giving any Sitemaps Details for a Domain property siteUrl. please give me any solution
Ah, thanks for the additional information. I see the same thing when trying to fetch a sitemap using the domain property URL.
$sites = $webmastersService->sites->listSites();
foreach ($sites as $site) {
$totalsitemaps = $sitemaps->listSitemaps($site->getSiteUrl());
}
It appears as though the List Sitemaps API does not support domain property urls at this time.
I suggest sending a report to the team using the "Submit Feedback" link in the bottom left corner of the Search Console. I'm very sorry for the inconvenience!
Since this issue isn't specific to the client library, but exists within the API itself, there's not much more we can assist with here, unfortunately. Again, I suggest letting the API team know your feedback; hopefully they can add the feature, or perhaps share some information that isn't obvious.
Best of luck!
@jdpedrie & @chiragvels,
While developing a new custom Google SC API implementation, I faced the same problem, against a SearchAnalyticsQueryRequest. Initially tried the root domains (and then also sub-domains - no matter the protocol, and even prefixing the URL with 'sc-domain:' did not help at first). We have lots of domain properties and root URLs/sub-domains registered and hit some oddities with implementation of this API. Not sure at this point what fixed it exactly but after going through some (but not ALL) additional Google domain re-verifications via DNS/TXT records and the varying website protocols (HTTP/HTTPS/etc), and waiting a while (hours, not days), the same queries against these endpoints/URLs returned expected results.
A key difference compared to the above is we did not have a need to query $webmastersService->sites->listSites(), but were initially experiencing the same types of errors when trying to access $webmastersService->searchanalytics methods.
Code snippets for reference (which is working ATM!):
$client = new Google_Client();
$google_private_key = variable_get('cw_google_private_key'); // The JSON file
$client->setAuthConfig($google_private_key);
$client->addScope('https://www.googleapis.com/auth/webmasters.readonly');
$webmastersService = new Google_Service_Webmasters($client);
$searchanalytics = $webmastersService->searchanalytics;
$url = 'sc-domain:example.com'; // WORKS!
$request = new Google_Service_Webmasters_SearchAnalyticsQueryRequest;
$request->setStartDate('2019-11-14');
$request->setEndDate('2019-12-14');
$request->setRowLimit(1000);
$request->setDimensions(array('page'));
$qsearch = $searchanalytics->query($url, $request);
$rows = $qsearch->getRows();
After some time passed, qsearch contains data rather than only errors. So for those of you that hit this problem - please fiddle with your Google Webmaster tools verification's:
https://www.google.com/webmasters/verification/home?hl=en
Then compare with the above PHP code, retry, and post your issues/observations here!
Glad to see our '$rows' result set now contains all Google results from the root level and subdomains of the $url variable!
@chiragvels did you submit the feedback and get any response?
@jdpedrie would it be an idea to keep this issue open until it is possible again to list sitemaps for domain properties?
@arch1v1st you describe that \Google_Service_Webmasters::$searchanalytics does support a format like sc-domain:example, but this does not allow us to load a sitemap, right?
The only way to be able to use the Sitemap API seems to be:
example.ext, use https://www.example.exthttps://www.example.ext instead of sc-domain:example.ext when communicating with the Sitemap API@holtkamp unless we determine that the issue lies within the PHP client library, there's no benefit in keeping it open, so far as I can see.
@jdpedrie yeah, I suppose you are right. My "problem" / the community's challenge is that this issue with domain properties seems to be around for some time and there is no place to report it other than the approach you suggested:
I suggest sending a report to the team using the "Submit Feedback" link in the bottom left corner of the Search Console
For what it's worth / future searchers: some other mentions I encountered on this topic:
@holtkamp I definitely understand the frustration. I suggest perhaps submitting this as an issue in the public issue tracker.
Thanks for the suggestion @jdpedrie, just created https://issuetracker.google.com/issues/166291453, hopefully it will set some things in motion 馃殌
I see that domain property is now listed in the documentation :
siteUrl | string | The URL of the property to add.聽Examples:聽http://www.example.com/聽(for a URL-prefix property) or聽sc-domain:example.com聽(for a Domain property)