GSC 6.2 selects the wrong property when multiple sites share the same account/client on Pro Reports

Title: GSC 6.2 selects the wrong property when multiple sites share the same account/client on Pro Reports

Summary

Pro Reports for different managed websites display identical Google Search Console figures and Top Pages belonging to another managed website.

Investigation of the installed source identified property-selection logic that matches only the account and client identifiers, then chooses the first matching property. The assigned gsc_property_id is loaded but omitted from the selection condition.

The report’s website ID and stored property assignment were verified as correct. Google Analytics figures and the report website URL change correctly between sites.

All domains below are anonymised.

Environment

  • Google Search Console extension: 6.2

  • MainWP Pro Reports: 5.1.7

  • Google Analytics extension: 6.1

  • Live WordPress installation on a Plesk-managed server

  • Service-account connection with access to multiple GSC properties

  • Custom report template using these tokens:

[gsc.total.clicks]
[gsc.total.impressions]
[gsc.ctr]
[gsc.average.position]
[gsc.top.pages]
[gsc.top.queries]

A previous connectivity problem was resolved by reconnecting the service account. This incorrect-property issue persisted afterward and was investigated separately.

Steps to reproduce

  1. Connect a GSC account/service account with access to several properties, for example:

    • https://site-a.example/

    • https://site-b.example/

    • https://site-c.example/

  2. Assign each property to its corresponding MainWP managed website.

  3. Ensure these assignments share the same gsc_account_id and gsc_client_id, but have different gsc_property_id values.

  4. Identify the first property in the stored property list matching that account/client pair. In this example, assume it is Site C.

  5. Generate reports containing the GSC tokens for Sites A and B, using the same date range. Use an uncached period or clear the relevant test cache.

  6. Compare the summary figures and Top Pages with each site’s assigned property.

Actual result: Sites A and B receive Site C’s GSC data.

Expected result: Each report retrieves data from its exact assigned GSC property, independently of the order of properties sharing the same credentials.

Diagnostic evidence

Read-only database checks found:

  • One assignment per inspected site; no duplicate assignments.

  • Different assigned property IDs.

  • The same account and client identifiers across the affected sites.

A runtime diagnostic for Site B confirmed:

MainWP website ID: correct for Site B
Assigned property: https://site-b.example/
Property selected by current lookup: https://site-c.example/

Both affected reports initially showed:

Clicks: 104
Impressions: 14.2K
CTR: 0.73%
Average position: 22.00

After exact property selection and refreshing the affected cache, Site B returned 45 clicks, 9.2K impressions, and its own Top Pages URLs.

Code finding 1: report property selection omits the assigned property ID

File:

mainwp-google-search-console-extension/class/class-mainwp-gsc-core.php

Method: get_gsc_data_by_date_range()

The method loads the assigned property ID:

$account_id = $website_gsc->gsc_account_id;
$prop_id    = $website_gsc->gsc_property_id;
$client_id  = $website_gsc->gsc_client_id;

However, the property lookup compares only account and client:

$current_properties = current(
    array_filter(
        $ga4_properties,
        function ( $property ) use ( $account_id, $client_id ) {
            return is_array( $property )
                && isset( $property['gsc_account_id'], $property['client_id'], $property['property'] )
                && (string) $property['gsc_account_id'] === (string) $account_id
                && (string) $property['client_id'] === (string) $client_id;
        }
    )
);

current() selects the first match. Subsequent API calls use $current_properties['property'].

The selection should also require the assigned property ID. For example, the predicate would need to capture $prop_id, validate the field, and include:

&& (string) $property['gsc_property_id'] === (string) $prop_id

If no exact property matches, the method should return an unavailable/error result rather than select another property.

Code finding 2: dashboard refresh contains the same omission

Same file, method: may_refresh_cached_gsc_stats_data()

$current_properties = current(
    array_filter(
        $ga4_properties,
        function ( $property ) use ( $account_id, $client_id ) {
            return $property['gsc_account_id'] === $account_id
                && $property['client_id'] === $client_id;
        }
    )
);

This lookup also omits the assigned property ID. Please review both paths, ideally using a shared exact-property resolver.

The GSC overview for one affected site also showed “No data available”, although we have not independently established that this symptom has the same cause.

Code finding 3: cached incorrect data can survive a lookup fix

Same file, method: get_gsc_date_range_cache_key()

private function get_gsc_date_range_cache_key( $website_id, $start_date, $end_date, $account_id, $client_id ) {
    return 'mainwp_gsc_report_' . md5( implode( '|', array( (int) $website_id, $start_date, $end_date, (string) $account_id, (string) $client_id ) ) );
}

The key includes the website ID, dates, account and client, but no property ID or property URL.

This does not cause a collision between website IDs. Instead, the wrong property’s data can be stored separately under each requested site’s cache key.

Please consider:

  • Including property identity in the cache key.

  • Invalidating existing contaminated report caches when releasing the fix.

  • Invalidating relevant caches when a property assignment changes.

  • Reviewing the separate dashboard statistics cache.

Temporary workaround and validation

A template-only workaround now:

  1. Resolves the property using property, account and client identifiers.

  2. Temporarily limits the in-memory property list to that exact match.

  3. Clears the specific site/date-range transient and retrieves fresh data.

  4. Supplies the six corrected tokens through mainwp_pro_reports_custom_tokens before initial replacement.

  5. Restores the original in-memory state in finally.

No core or extension files were modified to implement this workaround. Multiple sites were tested successfully, including correct first previews.

An earlier workaround on mainwp_pro_reports_parsed_other_tokens ran too late: the first preview could remain incorrect while the second used the corrected cache. Moving to the earlier custom-token hook resolved that workaround timing problem.

Requested action

Please confirm the findings against your maintained source and provide a permanent fix covering:

  • Exact property selection in report and dashboard retrieval.

  • Existing cache invalidation and property reassignment.

  • Correct results regardless of property-list order.

  • First-run and cached previews.

  • Multiple sites processed in one request.

  • Correct report periods and scheduled reports.

  • Missing/inaccessible properties without fallback to another site.

Please advise which release contains the fix and when the temporary template workaround can safely be removed.

Hey @creatorseo

Thanks for the detailed report and investigation. This looks valid, and we’ll address the property selection and caching issues in the next release of the Google Search Console Add-on.