简体   繁体   中英

whats wrong with my tracking code?

I am trying to set up cross domain tracking and also some other add on's as per the web developer reference guide but its not working.

When I use the google debugger it gives me this error: Uncaught SyntaxError: Unexpected token ILLEGAL

related to my this line of code: ga('create', 'UA-xxxxx-1', 'auto', {'allowLinker': true});

My full code is this:

 <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','//www.google-analytics.com/analytics.js','ga'); ga('create', 'UA-xxxxxx-1', 'auto', {'allowLinker': true}); ga('require', 'linker'); ga('linker:autoLink', ['destination.com']); ga('send', 'pageview'); ga('require', 'ecommerce'); ga('send', 'social', 'socialNetwork', 'socialAction', 'socialTarget', {'page': 'optPagePath'}); ga('send', 'timing', 'timingCategory', 'timingVariable', timingValue, 'optLabel'); ga('send', 'event', 'category', 'action', 'opt_label', opt_value, {'nonInteraction': 1}); ga('require', 'displayfeatures'); ga('require', 'linkid', 'linkid.js'); ga('send', 'pageview'); </script> 

id really appreciate any help as the code is no longer working and I cant track any analytics.

please help.

You'll need to update this line of code to include your tracking number. I'm seeing this from the snippet you pasted:

ga('create', ‘UA-xxxxxx-1', 'auto', {'allowLinker': true});

You should use this instead:

ga('create', 'UA-38001765-1', 'auto', {'allowLinker': true});

As well:

ga('linker:autoLink', ['destination.com']);

You are using ' instead of ' .

If your code still doesn't work, try going through the troubleshooting checklist: https://support.google.com/analytics/answer/1009683?hl=en . I know I've had issues in the past with other scripts on the page using the same variables as the Google tracking snippet uses.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM