Javascript _gaq.push不工作
这是我在head.php中的一段代码Javascript _gaq.push不工作,javascript,php,google-analytics,Javascript,Php,Google Analytics,这是我在head.php中的一段代码 <script type="text/javascript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-*******-*']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascri
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-*******-*']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
var _gaq=_gaq | |[];
_gaq.push([''u setAccount',UA-******-**');
_gaq.push([''u trackPageview']);
(功能(){
var ga=document.createElement('script');ga.type='text/javascript';ga.async=true;
ga.src=('https:'==document.location.protocol?'https://ssl' : 'http://www“)+”.google analytics.com/ga.js';
var s=document.getElementsByTagName('script')[0];s.parentNode.insertBefore(ga,s);
})();
下面是另一段代码:
<a href="tel:8976414707" class="order_btn order_btn_phone" onclick="_gaq.push(['_trackEvent', 'ClickToCall', 'CallRequest', 'Mobile', false]);">Order by Phone</a>
所以问题是我必须在已经建立的网站上工作,而代码的这一部分不起作用。谷歌分析对我来说是全新的一部分
有人能帮我知道这段代码的工作原理和错误是什么吗?看起来您的页面视图应该正常工作,但是您的事件不正确-您正在传递一个布尔值作为预期的数字时的事件值。如果不想传递任何内容作为事件值,可以使用
undefined
。但是,您可以只传递事件类别、操作和标签,因为默认情况下,最后一个参数(非交互)是false
在未定义的情况下
:
_gaq.push(['_trackEvent', 'ClickToCall', 'CallRequest', 'Mobile', undefined, false]);
没有事件值和事件非交互:
_gaq.push(['_trackEvent', 'ClickToCall', 'CallRequest', 'Mobile']);
更多信息您是否在web控制台中收到任何错误消息?这段代码在我看来很好,所以页面上一定有其他原因导致它无法工作。从2019年起,谷歌建议转到新的analytics.js。要实现事件跟踪,请参见此处