我在Google Analytics中跟踪事件时遇到问题。Google Analytics中的跟踪事件 - 点击
在网站代码中,我已经实现了GA的通用跟踪代码:
<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-xxxxxxx-xx', 'auto');
ga('send', 'pageview');
</script>
我想衡量链接的点击,所以我使用的onClick代码。
<a href="http://www.link.com" target="_blank" onclick="ga('send', 'mobile', 'click to call', 'clicks');">Anchor</a>
不幸的是,它不起作用。我不知道为什么。我也试过以前的公式(gaq)
<a href="http://www.link.com" target="_blank" onclick="ga('send', 'mobile', 'click to call', 'clicks');">Anchor</a>
但是两个代码都不起作用。
我做错了什么?