Create context-aware setup experience
Feature Description
There are a number of cases where users can't proceed with Site Kit setup due to the state of their site, for example on a staging environment where the production site hasn't been verified or added to Search Console.
Let's customise the setup flow to offer the right information at the right moments and help these users successfully configure Site Kit.
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
Once a user downloads and activates Site Kit, run the following checks in order:
-
Check if the host is “localhost” or using a common non-public TLD such as “.test” or “.local”
- If yes, the site is likely not publicly accessible → check whether the helper plugin is installed.
- if not installed → display custom text to prompt the user to install it.
- if installed → display custom text to prompt the user to complete required fields (e.g. OAuth credentials) and verify their production site.
- in either case, don't block the user from proceeding with setup (the "Start setup" button is still displayed)
- if not, proceed to check (2).
- If yes, the site is likely not publicly accessible → check whether the helper plugin is installed.
-
Generate token and store it in a temporary option; when this option is available, the plugin should output a meta tag in the frontend with a specific name attribute and the “random” token as value; then issue a GET request to the frontend.
- If the request fails, the site is likely not publicly accessible → check whether the helper plugin is installed.
- if the helper plugin is not installed → display custom text to prompt the user to install it.
- if the helper plugin installed → display custom text to prompt the user to complete required fields (e.g. OAuth credentials) and verify their production site.
- in either case, don't block the user from proceeding with setup (the "Start setup" button is still displayed)
- If the request succeeds, parse the meta tag.
- if it's not found, the site likely has caching issues → display custom text to prompt the user to temporarily disable any caching plugins.
- if it's found, all is well.
- If the request fails, the site is likely not publicly accessible → check whether the helper plugin is installed.
Custom text for 1.i.a. and 2.i.a.: Setup banner on Plugins page: Heading: Congratulations, the Site Kit plugin is now activated. Text: Looks like this is a staging environment. To use Site Kit, you'll need to install a helper plugin and verify your production site in Search Console. Learn how. Button: Start setup
Setup landing page: Heading: Site Kit is activated, but you need to complete some extra steps before you can see stats. Text: Looks like this is a staging environment. To use Site Kit, you'll need to install a helper plugin and verify your production site in Search Console. Learn how. Button: Start setup
Custom text for 1.i.b. and 2.i.b.: Setup banner on Plugins page: Heading: Congratulations, the Site Kit plugin is now activated. Text: Looks like this is a staging environment and you've already activated the helper plugin. To use Site Kit, make sure you've entered your custom OAuth credentials and verified your production site in Search Console. Learn how. Button: Start setup
Setup landing page: Heading: Site Kit is activated, but you need to complete some extra steps before you can see stats. Text: Looks like this is a staging environment and you've already activated the helper plugin. To use Site Kit, make sure you've entered your custom OAuth credentials and verified your production site in Search Console. Learn how. Button: Start setup
Custom text for 2.ii.a.: Setup banner on Plugins page: Heading: Congratulations, the Site Kit plugin is now activated. Text: Looks like you’re using a caching plugin that might interfere with setup. Temporarily deactivate the caching plugin while you're setting up Site Kit. You can reactivate the plugin after you finish setting up Site Kit. Button: Start setup
Setup landing page: Heading: Site Kit is activated, disable caching plugins to finish setup. Text: Looks like you’re using a caching plugin that might interfere with setup. Temporarily deactivate the caching plugin while you're setting up Site Kit setup. You can reactivate the plugin after you finish setting up Site Kit. Button: Start setup
For reference, here is the default text for both screens:
Setup banner on Plugins page:

Setup landing page:

Implementation Brief
Check if using a non-public hostname
- Parse the hostname from
home_url()to see if it islocalhostor ends in a reserved non-public TLD (.test,.example,.invalid, or.localhost- See RFC 2606)
Checking public accessibility
- Only done if host name check passes
- Generate a temporary token of random characters using
wp_generate_passwordand store it in a transientgooglesitekit_setup_test, with a short lifespan (5 min)- Render this token in a meta tag on the front end if set
- Extend
getExistingTagto support our newsetupmodule - Use
getExistingTag( 'googlesitekit-setup' )to check for added setup tag- If successful and token matches: test passed
- If successful and token does not match: test fail
- Inform the user to temporarily disable caching plugins
- If unsucccessful (request failed)
- Helper plugin installed?
- No - Prompt the user to install, activate, and configure the helper plugin
- Yes (inactive) Prompt the user to activate and configure the helper plugin
- Yes (active) Prompt the user to configure the helper plugin
- We probably shouldn't introduce additional code paths here based on helper plugin configuration values
- Helper plugin installed?
Installing Helper plugin
- Use one-click links to install helper plugin
https://github.com/WordPress/WordPress/blob/e19329bad085034cf0711788e4b08852045d746a/wp-admin/includes/plugin-install.php#L470$url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=' . $slug ), 'install-plugin_' . $slug ); - Generate this URL and provide it to the front end via
googlesitekit.setup.installHelperURL - Filter helper plugin data into
plugins_api(if not installed and active)
Changelog entry
- Inform the site owner about potential issues with their site that will likely cause problems when setting up the plugin.
@felixarntz from what I can see here, it seems like the only case where the user would be blocked from completing the setup is if they have no published posts or pages, is that correct? I'm curious why is this a requirement for completing setup? This seems a bit unlikely to ever happen since even a clean installation includes a published sample page and hello world post. Of course it's unlikely that a real site would keep these around, but the condition seems very rare nonetheless. It also assumes the site uses post and page post types, which although also unlikely could be possible.
Regarding the case where the site is not publicly accessible and the user is directed to use the helper plugin, are we then directing them to use their own GCP credentials? I would think this shouldn't be necessary now that we no longer rely on the REST API for receiving credentials for the proxy.
In the case to check for caching issues, I would think this should no longer be an issue as well now that we're using the file-based verification. Should we perhaps only do this check if the site does not support file verification which would require the use of a meta tag?
@aaemnnosttv There are a couple of additional nuances to why we need these checks - note that all of them are made to help the user or at least set their expectations in case something goes wrong later. For example, if we notice potential caching issues, and later they'll run into a problem because of that, it would be more likely they already have a hunch on possible paths to fix the problem.
To your specific questions:
it seems like the only case where the user would be blocked from completing the setup is if they have no published posts or pages, is that correct?
Yes, that's the only case where we should block the user. If there is de-facto no homepage and no content at all, there is no point in using Site Kit as of today, and UX would be bad because of SC and GA for example just rendering blue notice boxes. It could be useful to include other post types though as you suggest. Let's expand the check beyond posts and pages, and instead check if there is any post of any post type that is public.
Btw the only reason that we don't block users in the other two scenarios is that the checks are not reliable.
Regarding the case where the site is not publicly accessible and the user is directed to use the helper plugin, are we then directing them to use their own GCP credentials?
As discussed yesterday, the proxy does not properly support local sites, so the path of developer plugin + verified production site (see https://sitekit.withgoogle.com/documentation/using-site-kit-on-a-staging-environment/) is what we should continue to recommend for now. Actually, we should probably include a Learn more link to this documentation.
In the case to check for caching issues, I would think this should no longer be an issue as well now that we're using the file-based verification.
Caching issues are still relevant throughout different areas of the plugin. Verification is the most critical one, but we also do tag detection etc. Also file verification may fail for various other reasons, so meta verification is still a commonly used fallback method, so caching needs to be considered.
Btw the only reason that we don't block users in the other two scenarios is that the checks are not reliable.
Yes, of course, that makes sense.
As discussed yesterday, the proxy does not properly support local sites, so the path of developer plugin + verified production site (see https://sitekit.withgoogle.com/documentation/using-site-kit-on-a-staging-environment/) is what we should continue to recommend for now.
Oh, so we'll actually be sending them through the old set up flow then, correct? If so, this makes much more sense.
Caching issues are still relevant throughout different areas of the plugin. Verification is the most critical one, but we also do tag detection etc.
That's a good point, but both Site Verification and tag detection include a cachebuster parameter in the URL to get a fresh response of the page. In order to test this we would have to make two requests with different cachebuster parameters and assert that they were both the same. Either way I think two requests are necessary as there's no way to infer caching from a single request; that is - even if the expected meta tag is present in the response it could simply be a cache miss. The Site Verification API makes two requests as well, likely for this reason.
I also have concerns about doing this on page load, which will substantially increase the time it takes to see the page (especially on slower sites), so I don't think doing this would be a viable approach.
Another concern is related to how this messaging needs to show in both the plugin activation and splash screens (including legacy setup?), and how the two are independent in their implementations. It seems like the better experience here would be to create a shared React component which runs the tests asynchronously (we could even use getExistingTag for the cache test) and then both screens could use that to display their alternate verbiage. I realize that the activation notice does not currently use React though so that would be a substantial change there, but I think that would simplify the changes we need to make. Is there a reason why we can't use React for this notice?
Yes, that's the only case where we should block the user. If there is de-facto no homepage and no content at all, there is no point in using Site Kit as of today, and UX would be bad because of SC and GA for example just rendering blue notice boxes. It could be useful to include other post types though as you suggest. Let's expand the check beyond posts and pages, and instead check if there is any post of any post type that is public.
I don't think it's a good UX to block someone from installing the plugin before they're ready to publicise their content. It's possible a user might want to use Site Kit to set up Analytics on their site before they "go live", with a bunch of content that isn't public yet. It'd be better to display a notice on the dashboard mentioning "None of your content is public so we can't gather data on it yet." or something like that. But there are legitimate reasons to want to install Site Kit that don't have to do with viewing data, so I would not block installation based on an empty site.
I realize that the activation notice does not currently use React though so that would be a substantial change there, but I think that would simplify the changes we need to make. Is there a reason why we can't use React for this notice?
We'd need to load all our JS on the plugin page and add a new "React app" into it… but if the rest of the component is built with React I'd argue that's the way to move forward here. Having bits and pieces of the UI in PHP is quite a pain and leads to confusing development and disjointed—if not worse overall—UX. We could totally do it though; I'd be in favour of this approach for the activation screen. 👍
For implementing this, I'd strongly recommend moving to the React approach mentioned above: adding more features to the PHP-generated activation notice is annoying and error-prone, as we don't have the same linting, testing, and other tools available to us for the JS generated by PHP (https://github.com/google/site-kit-wp/blob/21aed60756bfb2e4c285cb22f4f8cab8edfa69a3/includes/Core/Util/Activation.php#L159). So I'd replace that section with code that enqueues a new googlesitekit-activation.js script that would create a new React screen. I know it seems like a lot of work to tweak a screen, but I think our time would be better spent moving that screen over to React rather and then making the React one great.
I don't think we should be checking for published posts or pages at all. Those kinds of checks are too error-prone; maybe they have some weird template/theme-generated page or something else that we won't detect but is live on their site. I think it's best to display a message in the case of no data than prevent sign-up based on us not seeing any data.
I have some issues with the term "staging environment" in text like "Looks like this is a staging environment". Staging environments are, typically, publicly-accessible websites (maybe behind authentication, but still on the public internet). If a user was on Pressable, for instance, their domain would be mysite.mystagingwebsite.com—that's a staging site, and it could be confusing for users to have their local site referred to as a staging site.
I don't mean to be a technical pedant, but I'd rather use more accurate language to describe non-public sites. "Testing", "non-local", and "private" all come to mind as better words. I worry about support requests when we are having users say they tried to install Site Kit "locally" but it tells them it's a "staging" website and how wires might get crossed.
@aaemnnosttv's points about needing to make two requests to verify cache-busting not working sounds right to me.
If there are any other questions/points you wanted me to cover @aaemnnosttv, just let me know! I feel like I already wrote too much 😉
Side note: this ticket is a lot to implement, and if we look to replace the existing Activation banner with a React component to share the code/unify the experience (recommended), I'd say that's best-served as its own, discrete issue that blocks this one. Otherwise this'll be way too big of a PR/issue, as it's already quite big.
@aaemnnosttv
In order to test this we would have to make two requests with different cachebuster parameters and assert that they were both the same.
The idea was to place a meta tag before making the request (only a single request with cachebusting parameter). If the meta tag is not included in the response, there may be issues.
I also have concerns about doing this on page load, which will substantially increase the time it takes to see the page (especially on slower sites), so I don't think doing this would be a viable approach.
That has been a concern we've also mentioned at some point - potentially this should happen in JS while the user sees a loading bar in the screen / activation notice.
@tofumatt I completely agree with the suggestion to refactor the activation notice to also use React. At the beginning the separation was okay, but now, if not before already, this is definitely growing out of reasonable proportions. I'll open an issue to refactor the notice as is shortly, that can be seen as an implementation prerequisite to this one, and thus will become a P0 too.
I have some issues with the term "staging environment" in text like "Looks like this is a staging environment". Staging environments are, typically, publicly-accessible websites (maybe behind authentication, but still on the public internet)
Let's for now keep the copy as outlined in the ACs, we can also revisit this later. Maybe we can rethink it to just state that it's not publicly accessible (technically, if a public site is behind authentication, it's still not actually publicly accessible from my POV).
@tofumatt I opened #991 and assigned it to you. Let's prioritize that first, and based on it continue working on the IB for this one. Implementation should only happen once #991 is merged.
@tofumatt @aaemnnosttv Updated the ACs to remove the content checks and related messages.
@aaemnnosttv
I like the idea of allowing to directly install the helper plugin from the UI, but that also introduces a bit more complexity. For example, before we show a link to install, we need to check whether the user can install_plugins. If not, I think the most reasonable solution would be to just not show the link and only refer to the documentation "Learn how".
Otherwise, IB ✅
I'll move this to "Blocked" though since #991 needs to be done first.
@felixarntz Would these checks only be run on the initial (first admin) setup or every time that the splash screen is shown? Particularly regarding the tag check, we should only do this if the user isn't already verified. If they end up on the splash screen to re-authenticate for some reason, I would think this shouldn't be triggered again.
Also, the AC states that the heading and text content are variable depending on the result of the tests. Does that imply that the whole surrounding component should be in some kind of loading state while the request is happening in the background? Obviously the host check could be done on load, but the tag check would require some time, which could be several seconds on some sites.
Should the "Start setup" button be available the whole time (allow the user to skip/ignore) the results of the test? It seems that this should probably always be available since none of the tests are blocking regardless of the result.
It seems like maybe that perhaps what is described here is more of a self-contained informational component, which would simply render in addition to what's already there, rather than changing around the existing language and wording, which could be quite confusing.
Maybe something like this?


Then the progress bar area would be replaced by the results of the checks and/or links to install helper plugin etc? This would be much simpler and an overall better experience for the user I think. What are your thoughts?
@aaemnnosttv
Would these checks only be run on the initial (first admin) setup or every time that the splash screen is shown?
I think we should only make these checks considering the site level, not user level. I think a good approach would be to only run the tests if there are no site credentials on the site yet. That would ensure it only happens once for the entire site basically (for the first admin) - whenever you reset, it would happen again, but that makes sense.
It seems like maybe that perhaps what is described here is more of a self-contained informational component, which would simply render in addition to what's already there, rather than changing around the existing language and wording, which could be quite confusing.
That would make sense to me, @marrrmarrr what do you think? Since we don't block the user in any case (since these are all assumptions), I think showing some kind of warning if there are potential issues would be a more consistent experience than changing headings.
I would say though that the button to proceed should be disabled until the tests have been completed, so that we ensure the user sees an eventual message if there is one needed for the setup.
Thanks @aaemnnosttv for this suggestion. Saving the user one click here and displaying the findings as some sort of warning is better option indeed! (I wasn't aware we could run these checks without a user-initiated event like clicking "start setup" when I wrote the initial ACs).
I've updated the ACs to match this new flow. What UI options do we have for displaying this warning that would fit the banner and the setup landing page?
After discussing this on today's call with @felixarntz we will start working on this and work out the appearance of the warning as we go. Regarding the UI, it would be great if there was an example we can borrow from that uses Material UI to fit the look and feel we are going for.
I also threw together a quick POC using some of the elements we already have as to how this might look

Tested
Local without helper plugin activated:

During setup flow user is presented with the following:

Local with helper plugin without creds

During setup flow user is presented with the following:

@aaemnnosttv can you confirm this is expected ^^?
@cole10up this is likely related to an issue with this property specifically. Try again using any other property and you should find it works as expected. DM me if you continue to have any problems with this.
Tested
AC 1
1.i.a Fired up a .test environment without the plugin installed, activated latest SK.

Notice the copy should be: Heading: Site Kit is activated, but you need to complete some extra steps before you can see stats. Text: Looks like this is a staging environment. To use Site Kit, you'll need to install a helper plugin and verify your production site in Search Console. Learn how. Button: Start setup
The copy doesn't match, also do we want the copy on the link to just say 'Install' like this? Or should it be more instructive? Also the padding between the ! icon and the copy is a bit large
Plugins Page:

Clicked the Install link drives user to:

Confirmed after 30 minutes clicking Install drives user her:

1.i.b After installing the helper plugin and keeping credentials blank

Notice the copy should be: Heading: Site Kit is activated, but you need to complete some extra steps before you can see stats. Text: Looks like this is a staging environment and you've already activated the helper plugin. To use Site Kit, make sure you've entered your custom OAuth credentials and verified your production site in Search Console. Learn how. Button: Start setup
The copy doesn't match also like the 'Install' for the above scenario do we want the copy to just say 'Configure' or something more instructive? Also, the padding between the ! icon and the copy is a bit large
Plugins page (not really a good scenario but checked anyway - having the helper plugin installed activated but not having the SK plugin activated)

Clicked configure, notice drives user to configure the plugin

Alternative scenario
Deactivated the helper plugin and checked setup:

Clicking activate activates the plugin. Do we want to adjust this button name to something more instructive?
Clicking Start setup for all 3 scenarios drives user here:

Happy path entering in credentials into helper plugin drives user to:

And subsequently here:

AC 2
2.ii.a
Adjusted the head to confuse SK into thinking its a site having aggressive caching (after working with @aaemnnosttv )

Notice the copy should be: Heading: Site Kit is activated, disable caching plugins to finish setup. Text: Looks like you’re using a caching plugin that might interfere with setup. Temporarily deactivate the caching plugin while you're setting up Site Kit setup. You can reactivate the plugin after you finish setting up Site Kit.
Plugins page:

Notice copy doesn't match and the padding between the ! icon and the copy is large
Clicking Setup for the above scenario:

Confirmed setup functions properly:

@marrrmarrr Please let me know your thoughts on my findings with the copy not matching the acceptance criteria the experience for the member when they click start setup for AC 1 and the padding between the ! icon and copy.
@cole10up regarding the copy changes, these were suggestions on my part that @marrrmarrr approved on the PR. As long as the condition and the overall message is correct, that's the important part.
As for the copy changing for each case regarding the status if the helper plugin, it adds more complexity than value I think. The issue originally described the CTA for the helper plugin more generically as an external link but we were able to make it much more streamlined for the user and use a more appropriate link text based on its status, but the rest of the copy doesn't really need to change IMO.
Notice copy doesn't match and the padding between the ! icon and the copy is large
This is a result of the two elements falling into different css grid cells. We could rework this part to make them closer if desired.
Moving to approval per comments from Evan.