Fix “Data error in Analytics. There was a critical error on this website while fetching data” in Site Kit by Google

Seeing this in Site Kit → Analytics?

Data error in Analytics
There was a critical error on this website while fetching data

In plain English, Site Kit tried to load Analytics data over the WordPress REST API and your site replied with a 500 critical error.

Most of the time that means:

  • A PHP fatal error in another plugin while Site Kit calls its Analytics endpoint
  • A plugin or theme conflict with Site Kit
  • A server level block such as mod_security or a firewall on REST requests
  • Less often, a broken or incomplete Site Kit or Analytics setup

Below is a safe path to confirm that Analytics tracking still works, then uncover which plugin, theme, or server rule is causing the critical error.

Site Kit by Google shows “Data error in Analytics. There was a critical error on this website while fetching data” on the Analytics screen. How do I fix this?

Short version

Site Kit is just the messenger here.

The message means:

“When I asked WordPress for Analytics data, your site threw a critical error.”

WordPress logs a PHP fatal during the REST request. Site Kit sees the 500 error and shows this generic message.

You normally fix it by:

  • Finding the real PHP error in debug.log
  • Checking for plugin or theme conflicts in Troubleshooting Mode
  • Resetting and reconnecting the Analytics module if needed
  • In stubborn cases, asking your host to fix server side blocks on the REST API

Use the index below to jump to your situation.

Quick navigation


Step 0. Check whether Analytics tracking still works

Very often this error affects only the Site Kit dashboard. Your site may still be sending hits to Google Analytics.

Check real time in Analytics

  1. Open Google Analytics.
  2. Pick the same property and data stream that Site Kit uses.
  3. Open the Realtime report.
  4. In another browser or an incognito window, visit your site as a normal visitor.

If you see at least one active user, tracking works. The issue is with how Site Kit reads and displays data, not with the tags themselves.

Verify tags with Tag Assistant

You can also use Tag Assistant to check that the Analytics tag fires on your pages.

If tracking is fine, you can focus on fixing the Site Kit UI error without panic. If tracking is broken as well, still follow the steps below, but pay extra attention to the Analytics module reset.


Step 1. If your site is not crashing, only the Analytics screen

In many cases the only symptom is:

  • Site Kit dashboard loads
  • The Analytics widget shows “Data error in Analytics”
  • Browser dev tools show a 500 error on a URL like/wp-json/google-site-kit/v1/modules/analytics-4/data/report

If the rest of your admin and front end works, you can leave Site Kit active while you troubleshoot.

If activating Site Kit blanked the whole site, deactivate it first so you can work:

  1. Log in to wp admin.
  2. Go to Plugins → Installed Plugins.
  3. Deactivate Site Kit by Google.

If you cannot reach wp admin at all, rename the plugin folder:

  1. Use FTP or your hosting file manager.
  2. Open wp-content/plugins/.
  3. Rename google-site-kit to google-site-kit-disabled.

WordPress will stop loading Site Kit. Once you have identified the underlying conflict, you can rename it back and reactivate.


Step 2. Enable debug logging and reveal the real error

The Site Kit message is just the surface. The fix lives in the PHP error just under it.

Turn on the WordPress debug log

If you do not already have a debug log:

  1. Connect over FTP or your file manager.
  2. Edit wp-config.php in your WordPress root.
  3. Above the line that says /* That's all, stop editing */ add or adjust:
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );
  1. Save the file.
  2. In wp admin go to Site Kit → Analytics until the error appears.
  3. Download or open wp-content/debug.log.

Look for errors at the time of the Analytics call

Search the log for:

  • google-site-kit
  • modules/analytics or analytics-4
  • Fatal error or TypeError

Typical patterns you might see:

  • A fatal in another plugin when Site Kit requests a report
  • A theme function running during REST requests that assumes a front end context
  • A server or JSON error that breaks the response

Write down:

  • The exact error message
  • The file path and line number
  • The plugin or theme folder in that path

This will tell you whether the culprit lives in Site Kit itself, another plugin, or your theme.

You can leave debug logging on while you test. Just remember to turn it off again later if you prefer.


Step 3. Use Troubleshooting Mode to find plugin and theme conflicts

Site Kit’s own docs recommend the Health Check & Troubleshooting plugin to isolate conflicts without breaking the front end.

Install Health Check & Troubleshooting

  1. In wp admin go to Plugins → Add New.
  2. Search for Health Check.
  3. Install and activate Health Check & Troubleshooting.

Enable Troubleshooting Mode with only Site Kit active

  1. Go to Plugins → Installed Plugins.
  2. Click Troubleshoot under Site Kit by Google.
  3. A Troubleshooting Mode bar appears at the top of wp admin.
  4. In that panel, make sure only:
    • Site Kit by Google
    • And possibly the Health Check plugin itself

    are enabled.

  5. Switch the theme in the panel to a default theme such as Twenty Twenty Four.

Now visit Site Kit → Analytics again.

  • If the error disappears with only Site Kit and a default theme, the problem is a plugin or theme conflict.
  • If the error stays even with only Site Kit and a default theme, this points more to:
    • A server or REST API configuration problem
    • Or a deeper Site Kit bug specific to your environment

If it is a conflict

Stay in Troubleshooting Mode.

  1. In the Troubleshooting panel open Available plugins.
  2. Enable one extra plugin.
  3. Reload Site Kit → Analytics.
  4. If the error does not return, enable the next plugin and repeat.
  5. When the error comes back, the last plugin you enabled is almost certainly involved.

Common conflict types:

  • Other Google Analytics or tag plugins that also talk to the Analytics API
  • Share or social plugins that load trackers on every admin page
  • Caching or security plugins that filter or block REST requests

Update that plugin to the latest version and check its settings. If you still get the error whenever it is active, contact that plugin’s support with:

  • The Site Kit error message
  • The PHP error from debug.log

You can then decide whether to keep that plugin, replace it, or wait for a compatibility fix.

When you are done testing, click Disable Troubleshooting Mode in the bar.


Step 4. Disconnect and reconnect Analytics inside Site Kit

If the PHP error lives in Site Kit code or in how it talks to Analytics, a clean reconnect can help.

Disconnect Analytics

  1. In wp admin go to Site Kit → Settings.
  2. Scroll to the Connected Services section.
  3. On the Analytics card click Edit.
  4. Click Disconnect Analytics from Site Kit.

This does not delete your Analytics property. It just disconnects Site Kit’s link to it.

Reconnect Analytics

  1. Still in Site Kit → Settings, click Connect more services or the Analytics card again.
  2. Go through the Analytics connection steps.
  3. Select the correct Analytics account, property, and data stream for your site.
  4. Finish the setup and return to Site Kit → Analytics.

If the error was caused by a bad property reference or a stale configuration, it often clears here.

If you created a brand new Analytics property during this process, remember that it can take some time before historic data appears. Use the Realtime report to confirm that hits are flowing.


Step 5. When it is a hosting or REST API issue

If the error still appears even with:

  • Only Site Kit active
  • A default theme
  • No obvious plugin level fatal in debug.log

then the problem is likely at hosting or server level.

Typical signs:

  • Site Health under Tools → Site Health → Status shows REST API errors
  • Site Kit 500 responses mention “invalid JSON response” or similar
  • Your host’s logs show firewall or mod_security rules firing for /wp-json/ requests

Refresh permalinks and .htaccess

  1. Go to Settings → Permalinks.
  2. Click Save Changes without changing anything.

This rewrites your .htaccess file, which can fix some REST routing issues.

Ask your host to check REST and Site Kit requests

Open a support ticket and include something like this:

I am using the "Site Kit by Google" plugin.

On the Site Kit Analytics screen I see:

"Data error in Analytics
There was a critical error on this website while fetching data"

When I check my browser console I see a 500 error on:

/wp-json/google-site-kit/v1/modules/analytics-4/data/report

And my wp-content/debug.log shows a generic critical error.

Can you please:

1) Check the server error log for the same time and tell me what PHP error occurs.
2) Confirm that requests to /wp-json/ and /wp-json/google-site-kit/ are not blocked by any firewall or mod_security rule.
3) Confirm that PHP and cURL meet Site Kit requirements and that JSON responses are not being modified or compressed in a non standard way.

If they find and fix a rule that was blocking or altering REST responses, the Site Kit error should go away the next time you open Analytics.


Step 6. What to send Site Kit support if it persists

If you still see “Data error in Analytics” after:

  • Checking tracking
  • Looking at debug.log
  • Running Troubleshooting Mode with only Site Kit and a default theme
  • Resetting the Analytics module
  • Having your host confirm that REST is not blocked

then it is time to reach out to the Site Kit team.

Include:

  • The exact message from Site Kit
  • The full PHP error from wp-content/debug.log that occurs when you open Site Kit → Analytics
  • Your WordPress, PHP, Site Kit, and Analytics versions
  • Whether you tested with only Site Kit active and a default theme using Troubleshooting Mode
  • Any notes from your host about REST API or firewall rules

You can open a topic in the Site Kit support forum or follow their “Fixing common issues with Site Kit” and “Using Troubleshooting Mode” docs, which both link to support.


Verification checklist

You are in good shape when:

  • The Site Kit Analytics screen loads without the “Data error in Analytics” message
  • Your browser console no longer shows 500 errors for /wp-json/google-site-kit/v1/modules/analytics-4/data/report
  • wp-content/debug.log has no new PHP fatals when you open Site Kit
  • Analytics Realtime shows visitors when you browse your site

Still stuck?

For AI help

Hit Continue Chat below and send:

  • The exact Site Kit error text
  • The PHP error from wp-content/debug.log around the time you open Site Kit → Analytics
  • A list of your main plugins that might interact with Analytics, caching, or security
  • Anything your host has already told you about REST API or firewall rules

I can help you read the log, narrow down the conflict, and phrase a clear message for Site Kit support or your host.

For expert human help

Scroll down to the contact form below. Enter your name, email, and WordPress needs. Atiba will get back to you as soon as possible.

Need human WordPress help?

WP Assistant is a free tool created by Atiba Software, a WordPress design and development company located in Nashville, TN. If you need more personalized WordPress assistance let us know, and we’ll get back to you ASAP!