Skip to content
Advertisement

Uncaught ReferenceError: _xxx is not defined – WooCommerce add_to_cart hook

I am using a SERVER-SIDE TRACKING for my woocommerce site.

In there I added a JS Tracking code snippet provided by company to the wp_head using

<script>
   add_action('wp_head', array(
            $this,
            'tracking_code'
        ));
</script>

, and

<script>
    _xxx.push({
       "track"     : "pageview",
    });
</script>

for all other events. All other events are working fine, but when I tried to fire the add to cart, it show the error :

Uncaught ReferenceError: _jts is not defined at ?add-to-cart=12:3:13

What can be the solution for this? Thanks for your time

Advertisement

Answer

The issue was the _xxx.push was loaded before the library loaded, fixed after added to footer.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement