Google analytics integration for orders without online payment transaction in Woocommerce 3
First check with the dummy data is its working fine or not.
add_action('wp_head','add_gscript_trans'); function add_gscript_trans(){?> <!-- Google Analytics --> <script> (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','https://www.google-analytics.com/analytics.js','ga'); ga('create', 'UA-130000602-1', 'auto'); /* To load the ecommerce plugin, use the following command: */ ga('require', 'ecommerce'); /* You add transaction data to the shopping cart using the ecommerce:addTransaction command:*/ ga('ecommerce:addTransaction', { 'id': '1234', // Transaction ID. Required. 'affiliation': 'Acme Clothing', // Affiliation or store name. 'revenue': '11.99', // Grand Total. 'shipping': '5', // Shipping. 'tax': '1.29' // Tax. }); /* Next, to add items to the shopping cart, you use the ecommerce:addItem command: */ ga('ecommerce:addItem', { 'id': '1234', // Transaction ID. Required. 'name': 'Fluffy Pink Bunnies', // Product name. Required. 'sku': 'DD23444', // SKU/code. 'category': 'Party Toys', // Category or variation. 'price': '11.99', // Unit price. 'quantity': '1' // Quantity. }); /* Finally, once you have configured all your ecommerce data in the shopping cart, you send the data to Google Analytics using the ecommerce:send command: */ ga('ecommerce:send'); </script> <!-- End Google Analytics --> <?php }
For more details see this link : E-commerce Track
Perhaps this page will help:
https://stackoverflow.com/a/54111464/7118098
Also, can't see the previous line where owl
is defined, but it looks like it's defined from a jQuery $()
from an element ID. Perhaps check that it exists and that owlCarousel isn't deferred and is indeed attached to the element you're referencing before .owlCarousel() is called on it.
Why don't you try WooCommerce Google Analytics Integration By WooCommerce or DuracellTomi's Google Tag Manager for WordPress By Thomas Geiger