Support » Plugin: WooCommerce Google Analytics Integration » Missing Quotation Mark on google-analytics.com/analytics.js

  • Resolved mystyleplatform

    (@mystyleplatform)


    Please view source on the example page and notice the line 210 where the plugin is dropping the Google Analytics tracking code to the page. There seems to be a missing quotation mark right before //www.google-analytics.jsga.

    This is throwing errors in Google Tag Manager checks as well as JS errors in the console.

    Thanks,

    – Sean

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Error in console is (index):211 Uncaught SyntaxError: missing ) after argument list

    I was able to patch this issue in file class-wc-google-analytics.php in your plugin by changing the line to include the protocol in the url, like:

    		$ga_snippet_head = "(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','" . self::tracker_var() . "');";

    If your site uses the woocommerce_google_analytics_script_src filter then I suggest that you patch /includes/class-wc-google-analytics-js.php with the following:

    
    $ga_snippet_head = "(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', '$src', '" . self::tracker_var() . "');";
    

    (starting at line 243)

    mystyleplatform

    (@mystyleplatform)

    We’re not using that filter, we’re just using WooCommerce Analytics and the popular Monster Insights analytics plugin. It looks like there was a patch released recently (1.4.14) and lists the missing quotation mark as the only update, so I imagine this is fixed. I will test soon.

    mystyleplatform

    (@mystyleplatform)

    Upgraded to 1.4.14 and tested. I can verify this issue is fixed for me. Closing this ticket.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Missing Quotation Mark on google-analytics.com/analytics.js’ is closed to new replies.