site-kit-wp icon indicating copy to clipboard operation
site-kit-wp copied to clipboard

Add Search Console domain property support and fix unreliable API requests

Open IgorCode opened this issue 7 years ago • 14 comments

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

  1. Install plugin
  2. 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 searchanalytics endpoint), 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_url filter) - 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_settings option has propertyID of 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-sites datapoint 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-sites is 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 / value props of the select element (this is currently causing a React error)
    • the tracking event add_new_sc_property should only be run when the property is actually new (and thus will be added by the POST:site datapoint); 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)
  • 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 avatar Jul 23 '19 20:07 IgorCode

@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.

jamesozzie avatar Jul 24 '19 09:07 jamesozzie

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.

cyberlicious avatar Jul 29 '19 14:07 cyberlicious

Same problem here. All domain properties now have https URLs in GSC.

madbradj avatar Jul 30 '19 14:07 madbradj

Having the same problem here.

evelyn avatar Oct 01 '19 23:10 evelyn

Having the same problem. Why does Google push users to use domain properties, but then not use them in their own plugin? Strange.

city17 avatar Nov 02 '19 11:11 city17

@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.

roadsunknown avatar Nov 12 '19 02:11 roadsunknown

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.

Todderz avatar Nov 21 '19 09:11 Todderz

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.

perandre avatar Dec 10 '19 13:12 perandre

I have the same issue. When will this problem be resolved ?

nesoor avatar Dec 29 '19 18:12 nesoor

Same Problem here! Can you tell us if you are intending to solve this? And if yes, by when?

simea-simea avatar Jan 08 '20 10:01 simea-simea

Same issue here. Existing and verified domain property in place. Google Site Kit creates a new property. Any news regarding a solution?

MicheleNL avatar Jan 29 '20 20:01 MicheleNL

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.

felixarntz avatar Jan 31 '20 11:01 felixarntz

IB ✅

aaemnnosttv avatar Feb 03 '20 10:02 aaemnnosttv

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 ✅

cole10up avatar Feb 13 '20 06:02 cole10up