What is the Google Analytics WP-Optimize feature?

This feature lets you improve your website’s page speed by using either a local copy of Google Analytics or a lightweight alternative called Minimal Analytics.

Serving Google Analytics locally

You can add Google Analytics to your site through a plugin or by adding the tracking script directly to your theme’s header, footer, or functions.php file. However, using the external Google Analytics script has some downsides:

  • External scripts, like Google Analytics, can get flagged by Google PageSpeed Insights for inefficient caching. External scripts also rely on the provider’s settings, which may not be ideal. This can hurt your PageSpeed score.
  • Google PageSpeed recommends limiting third-party scripts since each adds an extra DNS lookup, which slows performance.

You can improve your site’s speed by storing and serving Google Analytics locally instead.

Minimal Analytics

Minimal Analytics is a slimmed-down version of Google Analytics, reducing the impact of third-party scripts. The regular Google Analytics script is 52 KB, while Minimal Analytics is only 3 KB when gzipped. The trade-off? It only provides basic stats compared to the full Google Analytics dashboard.

For more details, check out the official Minimal Analytics page.

Which one should I use: Google Analytics or Minimal Analytics?

It depends on what you need. If basic stats are enough, Minimal Analytics is a great option. If you’re unsure, try Minimal Analytics first. You can always switch back to the standard Google Analytics if needed.

How do I use the WP-Optimize Google Analytics feature?

If you are currently using Google Analytics on your site, remove the script from any previously edited files such as header.php, footer.php and functions.php.  You may also need to remove the tracking ID from any other WordPress plugins you are using to prevent conflicts or inaccurate tracking.

1. Get your Tracking ID

You can find a detailed guide on obtaining your tracking ID directly from Google.

2. Enable Google Analytics

  • Go to WP-Optimize >> Minify >> Analytics
  • Click the Enable Google Analytics button
  • Enter your Tracking ID
  • Choose Google Analytics (Gtag.js) or Minimal Analytics
  • Click Save settings

Posted in: Google Analytics