_gaq.push之间有什么区别([' _trackPageview']);和ga(' send',' pageview');

时间:2014-12-17 04:48:50

标签: javascript google-analytics seo

我有以下代码

<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-XXXXXXXXXXXX-1', 'auto');
          ga('send', 'pageview');

        </script>

<script type="text/javascript">
/* <![CDATA[ */
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXXXXXXX-1']);
_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);
})();

(function(b){(function(a){"__CF"in b&&"DJS"in b.__CF?b.__CF.DJS.push(a):"addEventListener"in b?b.addEventListener("load",a,!1):b.attachEvent("onload",a)})(function(){"FB"in b&&"Event"in FB&&"subscribe"in FB.Event&&(FB.Event.subscribe("edge.create",function(a){_gaq.push(["_trackSocial","facebook","like",a])}),FB.Event.subscribe("edge.remove",function(a){_gaq.push(["_trackSocial","facebook","unlike",a])}),FB.Event.subscribe("message.send",function(a){_gaq.push(["_trackSocial","facebook","send",a])}));"twttr"in b&&"events"in twttr&&"bind"in twttr.events&&twttr.events.bind("tweet",function(a){if(a){var b;if(a.target&&a.target.nodeName=="IFRAME")a:{if(a=a.target.src){a=a.split("#")[0].match(/[^?=&]+=([^&]*)?/g);b=0;for(var c;c=a[b];++b)if(c.indexOf("url")===0){b=unescape(c.split("=")[1]);break a}}b=void 0}_gaq.push(["_trackSocial","twitter","tweet",b])}})})})(window);
/* ]]> */
</script>

有谁可以告诉我两者之间的区别是什么?

2 个答案:

答案 0 :(得分:3)

最简单的答案:ga()是通用分析(analytics.js),_ gaq.push是经典分析(ga.js)。

答案 1 :(得分:-2)

基本上......

ga('send', 'pageview');

...是:&#34;通过网页跟踪,您可以衡量网站上特定网页的观看次数。&#34;这会发送页面,位置和标题信息或跟踪页面点击。

_gaq.push(['_trackPageview']);

...基本上是发送一系列数据点的命令。基本上,对象是使用各种数据构建的,此命令会推送收集的数据。可以发送的不仅仅是页面查看跟踪数据。

更新

  • _gaq :经典分析
  • ga :通用分析