If you use WooCommerce and Klaviyo’s onsite tracking and signup forms aren’t working, it could be due to the WordPress plugin WP Rocket blocking certain features of Klaviyo. If you are using WP Rocket and encounter this problem, there are two ways to solve it.
What is WP Rocket?
WP Rocket is a caching and page speed optimization plugin for WordPress which speeds up WordPress sites.
What’s causing the problem?
One feature of WP Rocket is File Concatenation (an option that can be toggled on and off) which combines external JavaScript sources. This unfortunately breaks Klaviyo’s onsite JavaScript and, as a result, signup forms and onsite tracking will not work.
How do I fix it?
WP Rocket has two different options to fix the problem by allowing Klaviyo’s plugin to properly load our onsite JavaScript, and thus enable onsite tracking and signup forms:
-
Exclude external JavaScript from concatentation: This option excludes Klaviyo’s JavaScript from concatenation on your site by adding it to your WP Rocket excluded JavaScript files list. You can learn more about where to do this in this WP Rocket documentation. With this option, you’ll need to add the following lines of code, as two separate lines, to your WP Rocket excluded files:
static.klaviyo.com
/wp-content/plugins/klaviyo/(.*).js -
Disable the option “Combine JavaScript Files”: This option toggles off JavaScript concatenation for your entire site. You can learn more about where to do this in this WP Rocket documentation.