site-kit-wp: URLs displayed with duplicate path segment (for language/WPML, but also generally)

Bug Description

Modified for UI issue only

URLs are displayed with a duplicate path when using the WPML plugin different languages in directories setting with the use directory for default language sub-option checked:

WPML different languages in directories

Site Kit chooses the default language URL as the Site URL:

Screen Shot 2020-04-10 at 11 09 40 AM

URLs reported in the UI append the directory additionally:

Screen Shot 2020-04-13 at 6 36 05 PM

Further context about the setting:

https://wpml.org/faq/server-setting-for-languages-in-directories/ https://wpml.org/documentation/getting-started-guide/language-setup/cannot-activate-language-directories/

Related support topic:

https://wordpress.org/support/topic/doesnt-handle-multiple-languages-correctly/


Do not alter or remove anything below. The following sections will be managed by moderators only.

Acceptance criteria

  • Site Kit should be fully compatible with WPML.
  • In particular: with the WPML settings: “different languages in directories” and “use directory for default language sub-option” checked, and the SiteURL set to {domain}/{default_language}, the URLS displayed in the “Top content over the last 28 days” table on the WordPress Dashboard, and for the “Most popular content” table on the Site Kit Dashboard should appear correctly.

Implementation Brief

links[ i ] = siteURL + url; should change to links[ i ] = url;

QA Brief

Changelog entry

  • Display only paths instead of full URLs in Analytics tables for better visibility and consistency with Analytics frontend.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 21 (8 by maintainers)

Most upvoted comments

@adamsilverstein Can you update the IB to account for the decision of showing only paths? Would be good to include where to do it (we have multiple places, like dashboard, Analytics module page, WP dashboard widget).

Looking at the code, in the plugin displays full URLS when displaying the “Top content over the last 28 days” on the WordPress Dashboard, and for the “Most popular content” List on the Site Kit Dashboard.

These data points come from the Analytics API, which returns paths (not full urls). The plugin constructs the url to display by appending the item path to the site URL:

https://github.com/google/site-kit-wp/blob/d0c0d9dc0f89e8516d17eb8b78d600a1780130ac/assets/js/modules/analytics/dashboard/dashboard-widget-popular-pages-table.js#L83

https://github.com/google/site-kit-wp/blob/d0c0d9dc0f89e8516d17eb8b78d600a1780130ac/assets/js/modules/analytics/wp-dashboard/wp-dashboard-widget-top-pages-table.js#L52

In the case of the user reporting the issue, I suspect that they have configured {domain}/{default_language} as their WordPress site URL (which matches the WPML configuration where users put their default language into a subfolder). When the Analytics API responds with the full file path, the resulting constructed path duplicates the /{default_language} part.

For the purposes of displaying URL’s we should construct the URLs to display by using only the domain name from the siteURL before adding the API returned path.

Updated AC accordingly and asked follow up questions on the support thread.

@ernee - Regarding the WPML plugin, I did some testing with the latest version of wpml and site kit. Running with languages in a subdirectory, setup worked fine and was not blocked…

Some things worth noting:

  • My site was set up in search console and verified as {domainname}/default_language - meaning by default I wouldn’t get Search Console data for any other languages. If the user wanted to collect data for all languages they could probably set up a domain property (for {domainname}) in search console and connect to that in the setup flow (it is offered during setup in a dropdown if found).

  • For Analytics, I see the tag output on both sites so data for all languages would be combined in the display. This feels like expected behavior.

Tested on a jurassic.ninja My settings:

image

I haven’t been able to recreate it, but should this be a separate issue ?

This is likely a related issue so you can leave it here. All these redirect_uri errors are at least potentially related to the issue we are working on in https://github.com/google/site-kit-wp/issues/1357 - and will be resolved with the fixes there.