google / site-kit-wp

Site Kit is a one-stop solution for WordPress users to use everything Google has to offer to make them successful on the web.
https://sitekit.withgoogle.com
Apache License 2.0
1.25k stars 291 forks source link

Compatibility with headless WordPress environments #1347

Closed ernee closed 4 years ago

ernee commented 4 years ago

A user in the support forums encounters the following error when attempting to verify their site in a headless WordPress environment:

The necessary verification token could not be found on your site.

The user tried using both the plugin's setup process and with the staging environment/ Dev settings plugin to get their data from the main site (https://example.com) to the headless WordPress instance (https://cms.example.com). The main website is already verified in Search Console via DNS, but their attempt still results in the error.

The user additionally noticed the following when using the Dev settings plugin:

Other details:

See topic for more details: https://wordpress.org/support/topic/problems-with-headless-wordpress/

aaemnnosttv commented 4 years ago

The plugin does not fully support a headless setup at the moment.

The site verification step in particular that Site Kit helps facilitate, will not work in a headless setup be cause it relies on WordPress serving the request so it can render the necessary HTML file or meta tag.

As for Site Verification specifically, this can be done manually, without using Site Kit at all (e.g. DNS, or by manually deploying the necessary file/meta tag to the headless app). To verify your user manually, the user can use https://www.google.com/webmasters/verification/home and click the button to "Add a Property".

Since the user is using their own GCP credentials, it may allow them to complete the set up.

Generally speaking though, the plugin does not even support using different domains for wp-admin and the frontend (headless or not) but this may not apply to this user in particular since they're using their own credentials.

felixarntz commented 4 years ago

@ernee Indeed, headless setups are not supported, specifically because such setups defeat one of the purposes of Site Kit, which is to make Google service integration, tag management etc. seamless. But on a headless site, placing something in the frontend like we do is impossible.

The user can still use Site Kit still for monitoring, and would have to manually place all the tags they need (e.g. Analytics, AdSense, etc.). In order to do so, they need to use the Dev Settings plugin like they already do. The missing part is that they need to manually verify the WordPress instance site (https://cms.example.com) too in order for the verification step to succeed.

Support for this kind of setup would become slightly better once the authentication service supports development sites properly, but fully supporting headless WordPress isn't something currently prioritized.

rodrigo-arias commented 1 week ago

@felixarntz It’s a shame that, with the growing number of headless sites, there isn’t a way to set up this great plugin. Would it be possible to configure the plugin to allow users to view metrics, even if an alert indicates that script integration needs to be handled manually? Even with limited support, using the plugin for metrics could still be very valuable in headless environments.