Add Search Console domain property support and fix unreliable API requests
Bug Description
Plugin added a new property instead of using an already existing domain property. Now I have domain property + URL property for the same website. I already had this URL property and removed it when GWT introduced domain properties, I obviously do not want this new URL property in my GWT.
Can the Search Console integration be improved so that user manually select the property where their website belongs? How can I switch to domain property now?
Steps to reproduce
- Install plugin
- Authenticate via OAuth
Screenshots
-
Additional Context
- PHP Version: 7.2.20
- OS: Windows
- Browser: Chrome 75.0.3770.142
- Plugin Version: 1.0.0-beta.1.0.2
- Device: PC
Similar to #281 #285
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
- The plugin and authentication service should both detect matching Search Console domain properties (partly internal task, updating the authentication service).
- For the authentication service flow, the actual property ID should be detected and then stored, instead of storing the site URL as property.
- When making requests to Search Console (e.g. its
searchanalyticsendpoint), the plugin should always use the property ID stored instead of "assuming" that the site URL is the Search Console property ID. - The Search Console property should in no way affect the site reference URL (it currently does so via the
googlesitekit_site_urlfilter) - this is closely related to the above, the site URL shouldn't be relied on to make SC API queries. - The local setup screen should not result in a JS error if there are more than one matching SC property.
QA Brief
- Set up a Search Console domain property for the WordPress site (ensure there is no other Search Console property for that site).
- Install and activate Site Kit on that site (make sure it is new/reset).
- Go through the setup flow.
- Ensure that...
- the existing domain property was detected on the authentication proxy (fixed on the service), i.e. the service did not create a(nother) regular URL property for the site
- Site Kit detected the domain property (
googlesitekit_search-console_settingsoption haspropertyIDof the domain property, e.g.sc-domain:example.com) - Search Console areas in dashboard and its own module screen show data as expected and no permission errors
Implementation Brief
- Simplify
GET:matched-sitesdatapoint to only return a single array of matched properties. Include the checks for sufficient permission levels in the datapoint so that it is centrally handled - an unverified property should never be exposed here. - Update logic in
assets/js/components/setup/search-console.js:- should expect new API response structure
- the request to
GET:matched-sitesis currently made twice, which is unnecessary because the logic executed if there is just one match is the same - no full site/property objects should be passed to the
label/valueprops of the select element (this is currently causing a React error) - the tracking event
add_new_sc_propertyshould only be run when the property is actually new (and thus will be added by thePOST:sitedatapoint); currently it is also run when the user selects an existing property
- When receiving a token via the proxy for the first time, detect the real Search Console property and store it, instead of assuming the site URL
- use
get_data( 'matched-sites' )to get the list - if there's only one result, use that
- if there are multiple, try to use one that is a URL property (preference over domain property)
- use
- Update
Search_Console::create_search_analytics_data_request()to rely on the currently set property instead of the site URL (assuming that is the property, which it may not be, and thus result in permission errors) - remove filter that replaces the reference site URL with the Search Console property stored; this was already problematic before, but really is now, since a domain property is not a URL
- see #1086
Changelog entry
- Add missing support for Search Console domain properties and rely on the correct property when requesting Search Console data.
@IgorCode Domain properties require DNS verification, so it's a more complex process. It's also a recently added feature to web console. That being said I will add it for consideration as a feature request for future releases.
Ditto for us on this request please. After updating all of our partners in GSC to Domain Property and removed their HTTP, HTTPS and non-www properties, we had to go back to add their HTTPS property in order to use the plugin for their sites.
Same problem here. All domain properties now have https URLs in GSC.
Having the same problem here.
Having the same problem. Why does Google push users to use domain properties, but then not use them in their own plugin? Strange.
@jamesozzie Domain properties require DNS verification, so it's a more complex process.
If the domain property is already verified, the plugin does not need to re-verify. The issue is not to create new domain properties, only to check if a property already exists and map to existing property.
Ditto. Domain property already created and verified. Now I have http and https properties because of site kit, and site kit shows verification errors every time I log in, even though it's been previously verified nd linked.
Same issue here: Existing & verified https://www.example.com is not used, but http://www.example.com is added to SC.
I also tried deleting the property with HTTPS in SC directly, then re-installing Site Kit. Same issue: Even though the site is forcing https (and www), Site Kit insists on adding a new property http://www.example.com.
I have the same issue. When will this problem be resolved ?
Same Problem here! Can you tell us if you are intending to solve this? And if yes, by when?
Same issue here. Existing and verified domain property in place. Google Site Kit creates a new property. Any news regarding a solution?
We've found out what has been happening here, there are several smaller issues in the plugin that cause this. We'll prioritize a fix for next release.
IB ✅
Tested
Setup SK with a Search Console domain for the site for the first time, went through setup and confirmed the QA brief below:
Ensure that the existing domain property was detected on the authentication proxy (fixed on the service), i.e. the service did not create a(nother) regular URL property for the site PASS Site Kit detected the domain property (googlesitekit_search-console_settings option has propertyID of the domain property, e.g. sc-domain:example.com) PASS Search Console areas in dashboard and its own module screen show data as expected and no permission errors PASS
Passed QA ✅