Recently I added possibilities for WordPress developers to modify CAOS’ tracking snippet using filters. Shortly afterwards I received an inquiry on the support forum asking if I could integrate Google Optimize in CAOS.
Instead of continuously releasing updates, I figured I’d just explain, how you can write your own WordPress plugin, and integrate it into CAOS yourself.
What is Google Optimize?
Google Optimize is a tool for A/B-testing. In other words, it allows you to test different versions of your web pages to see how they perform against an objective you’ve specified.
But a proper test contains measurements. How did your visitors behave when served version A of page X compared to version B? That’s why Google invented Optimize as a plugin for Google Analytics.
The Wait is Over.
Get the Newsletter you've always wanted, now!
Sign up to receive Biweekly, Free Optimization Tips for WordPress.
No spam. I promise.
Use CAOS with Google Optimize
You’re running your online business and like any other business you want to tweak it to maximize its performance. Duh, you’re smart. That’s why you’re using CAOS.
But to squeeze more performance out of your online business, you figured you need A/B tests. Well, you must’ve been the World’s Happiest Camper© once you realized you could easily combine the two!
Since v3.4.0 CAOS natively supports Google Optimize integration. Simply go to the plugin’s Extensions tab, enable the option and enter your Google Optimize Container ID. Enjoy!
The snippet of code is really straight forward. It hooks into the recently added
caos_process_settings action and adds the specified
$optimizeId to its configuration.
Request my CAOS Expert Configuration service if you’re not comfortable writing code and/or you need another custom integration. Read more
Mind you that this snippet will only work with
gtag.js enabled in CAOS. (Why
Simply copy the above code into a file called
caos-google-optimize.php, insert your Optimize ID in the position of the placeholder (make sure to place it in between the quotation marks to prevent Syntax Errors) and save it inside WordPress’ plugins-folder, e.g.
/path/to/wordpress/wp-content/plugins/caos-google-optimize.php. Or, if you want to save yourself the hassle, download this mini plugin for WordPress from Github!
Enable your mini Plugin for CAOS
Now, visit the Plugins screen inside your WordPress Administrator area. You’ll notice a new plugin, called Google Optimize for CAOS. Activate it like you normally would and off you go! If you’re using any caching plugins, make sure to flush all caches.
And that’s it! You have now successfully integrated Google Optimize into CAOS! I hope this tutorial was clear enough. If you have any remarks or questions, please leave a comment.