我正在尝试按照网络开发人员引用指南设置跨域跟踪以及其他一些附加组件,但它不起作用。
当我使用谷歌调试器时,它给了我这个错误: 未捕获的语法错误:意外的标记非法
与我的这行代码相关: ga('create', 'UA-xxxxx-1', 'auto', {'allowLinker': true});
我的完整代码是这样的:
<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 非常感谢任何帮助,因为代码不再工作并且我无法跟踪任何分析。
请帮忙。
最佳答案
您需要更新这行代码以包含您的跟踪号码。我从您粘贴的代码片段中看到了这一点:
ga('create', ‘UA-xxxxxx-1', 'auto', {'allowLinker': true});
你应该使用这个:
ga('create', 'UA-38001765-1', 'auto', {'allowLinker': true});
还有:
ga('链接器:autoLink', ['destination.com']);
您正在使用‘
而不是'
。
如果您的代码仍然无法工作,请尝试查看故障排除 list :https://support.google.com/analytics/answer/1009683?hl=en 。我知道过去我在使用与 Google 跟踪代码段相同的变量的页面上的其他脚本时遇到过问题。
关于javascript - 我的跟踪代码有什么问题吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28225390/