CAOS - Complete Analytics Optimization Suite

The Complete Analytics Optimization Suite (CAOS, Formerly Known As “Host Analytics.js Local”) is a cool plugin for WordPress. It allows you to fine-tune your websites’ performance by enabling you to self-host Google’s Analytics Javascript file. Optimize analytics by simply entering your tracking ID and let the plugin do the rest! It places the necessary code in your theme’s header (or footer) and downloads the analytics.js file to your server. Then the file is updated automagically using WordPress’ integrated wp_cron() function.

How to Optimize Analytics in WordPress?

I get a lot of questions regarding the optimization of WordPress websites. Especially when people use Google’s own Pagespeed Insights they never seem to be able to get a perfect score. How do you leverage browser cache when Google’s very own Analytics.js has it’s expiry time set to 2 hours? How do you minimize DNS requests when Google advices you to copy their tracking code, linking to an externally hosted Javascript file?

If that isn’t bad enough already, Google’s advice is to avoid hosting the JavaScript file locally. And why? To ensure you get access to new features and product updates.

Why should I host analytics.js locally?

The Complete Analytics Optimization Suite for WordPress gives you the best of both worlds. After activation it automagically downloads the latest version of analytics.js from Google’s servers, places the necessary tracking code in your WordPress theme’s header and keeps the local Javascript file up-to-date using an adjusted version of Matthew Horne’s update analytics script and wp_cron(). This way you can minimize DNS requests, leverage browser cache, track your visitors and still follow Google’s recommendation to use the latest features and product updates.

Since version 1.30 the plugin supports more ways to optimize Analytics in WordPress. By loading your tracking code in the footer of your theme, you can eliminate render-blocking Javascript and CSS in above-the-fold content. The usage of adjusted bounce rate allows you to fine-tune your bounce rate for more realistic results.

Configure CAOS in WordPress

The basic configuration for CAOS is very easy. The basic settings are required for proper functioning of the plugin.

Basic Settings

  1. Configure CAOS Basic Settings
    Configure CAOS Basic Settings

    Enter your Google Analytics Tracking ID,

  2. For GDPR Compliance, decide when you want to allow tracking
  3. Decide where you want to load the generated tracking code
    • Choose ‘Header’ for best performance. Because the tracking code is loaded before the rest of the page, you’re sure that all visitor data can be registered by Google Analytics,
    • Choose ‘Footer’ (not recommended). This used to be necessary, because in some cases Google Pagespeed would throw an ‘eliminate render-block Javascript in above-the-fold content’-notice. This would cause the snippet to be loaded after everything else,
    • Choose ‘Add manually’ to maximize compatibility. If your theme or another plugin is preventing CAOS from adding the tracking code automatically, choose this option and copy the generated tracking code from the field underneath.
  4. Choose between the default (synchonous, i.e. render blocking) tracking code or the asynchronous tracking code.
  5. If you haven’t already, remove any other previously installed Google Analytics plugins or manually inserted tracking code from your WordPress installation.

Advanced Settings

To tailor CAOS to your needs you can use the Advanced Settings. None of these are required settings and are strictly meant for advanced (WordPress) users.

Notice: if you have no idea what any of the below options mean, just leave them blank as they could seriously alter your Google Analytics reports.
  • CAOS does not offer an Analytics Dashboard for WordPress or Enhanced Commerce tags/events. To implement these features, CAOS is fully compatible with Monster Insights, Analytify, WooCommerce GA Integration and ExactMetrics.
  • Enable Stealth Mode to bypass Ad Blockers and secure Google Analytics’ accuracy.
  • Choose to download analytics.js, ga.js or gtag.js and analytics.js together. Need help choosing?
  • Set a ‘Cookie Expiry Period‘ if you want to let the Google Analytics-cookie expire after a set number of days.
  • You can use the ‘adjusted bounce rate‘ if you want to filter out e.g. visitors that close their browser window within a set number of seconds. This can be useful if you offer short snippets of information on your blog that don’t trigger a user to continue reading other pages, such as StackOverflow.
  • Expert Level: Change the Enqueue Order of the script if you notice that other JavaScript’s might be interfering with the execution of your Google Analytics tracking-code. I suggest leaving this to the default (0), to assure the script being triggered before everything else.
  • Expert Level: Disable all Display Features if you want to force disable any remarketing purposes set in your Google Analytics Dashboard.
  • In some countries it is required to Anonymize the IP Address of your visitors e.g. Germany. For GDPR Compliance you should enable this option if you live in such a country.
  • Expert Level: For testing purposes you could enable tracking logged in Administrators. Be warned that this can seriously alter your Analytics statistics.

Further Reading


Click here to go to the WordPress Repository and download Complete Analytics Optimization Suite