• Resolved digitalawakening

    (@digitalawakening)


    First, thanks for the plugin! I’m using the latest version of the plugin, without any third party analytics plugins. I have add tracking code checked, display advertising unchecked, universal analytics checked, ecommerce tracking checked, and event tracking checked.

    I was debugging ecommerce tracking, which hasn’t been working for me. When completing a transaction and arriving at the thank you page, where the ecommerce javascript is injected, I was receiving an error message in the Chrome Developer Tools, which is how I found out that the JavaScript output by the plugin’s ecommerce_tracking_code function was being filtered somewhere (with autop?) and had a bunch of <p> and </p> tags in the middle of the script, causing it to fail.

    I tried for awhile to mess around with autop and shortcode_unautop in my functions.php, but couldn’t find a way to stop that script from being mangled. So as a temporary workaround, I removed the extra linebreaks in the ecommerce_tracking_code function (e.g. line 230) so that they wouldn’t be wrapped with <p></p>. Now it’s working for me.

    Could you see if you can duplicate this, and incorporate a fix in the next release? This might be what is causing ecommerce tracking to fail for other users.

    https://wordpress.org/plugins/woocommerce-google-analytics-integration/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hey digitalawakening,

    I just tested this on my own end with the same settings and couldn’t reproduce it. 🙁

    This is what I see on the thank you page:

    <script type="text/javascript">
    			(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','//www.google-analytics.com/analytics.js','ga');
    
    			ga('create', 'UA-1234567890-1', 'auto');
    			ga('set', 'dimension1', 'no');
    			ga('send', 'pageview');
    
    			ga('require', 'ecommerce', 'ecommerce.js');
    
    			ga('ecommerce:addTransaction', {
    				'id': '#112',      // Transaction ID. Required
    				'affiliation': 'WC Core', // Affiliation or store name
    				'revenue': '75',        // Grand Total
    				'shipping': '0',    // Shipping
    				'tax': '0'         // Tax
    			});
    			ga('ecommerce:addItem', {'id': '#112','name': 'Simple','sku': '9','category': 'food','price': '75','quantity': '1'});ga('ecommerce:send');      // Send transaction and item data to Google Analytics.</script>

    Screenshot: http://cld.wthms.co/RiTJ

    Thread Starter digitalawakening

    (@digitalawakening)

    Thanks for your reply Patrick. It must be something specific to my setup, functions.php, or other plugin interactions. Thanks for trying to reproduce it.

    You’re welcome – have you tried disabling all plugins (just as a test)? If that fixes it then you can enable them one by one to find the conflict.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Dynamically output JavaScript fails due to tags’ is closed to new replies.