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
or gtag.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
For a complete impression of what CAOS has to offer and its configuration, refer to the user manual.