Google Analytics跟踪GA.js与Analytics.js

sah*_*d24 2 google-analytics event-tracking analytics.js

我正在尝试使用此代码来跟踪Google Analytics中的事件

    _trackEvent(category, action, opt_label, opt_value, opt_noninteraction)
Run Code Online (Sandbox Code Playgroud)

这似乎意味着与GA.js Analytics"包"一起使用,但我使用的是Analytics.js

像这样

    (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');
Run Code Online (Sandbox Code Playgroud)

有没有办法我甚至可以用这段代码跟踪?或者我必须使用

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-XXXXX-X']);
  _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);
  })();
Run Code Online (Sandbox Code Playgroud)

我需要这两个代码吗?或者只使用Analytics.js有一些不同的方式

提前致谢

**编辑:事实上,我可能没有解释我想要的东西,甚至可能都没有.我想使用Funnels on Events,我想使用_trackEvent(这是我认为它会做的)将用户标记为已输入漏斗,如果事件发送则我们将拥有正常的漏斗.因此,如果10个用户进入该页面并点击该按钮,我将在漏斗上有10个事件,并取得1个成功

Cra*_*ent 6

analytics.js将向旧的代码报告GA,但它具有不同的语法,因此您无法使用_trackEvent.

以下是使用analytics.js基本页面语法链接,此处是使用analytics.js进行事件跟踪的链接

<!-- Google Analytics -->
<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-XXXX-Y');      // GA account ID goes here
ga('send', {
  'hitType': 'event',           // Required.
  'eventCategory': 'category',  // Required.
  'eventAction': 'action',      // Required.
  'eventLabel': 'opt_label',
  'eventValue': opt_value,
  'nonInteraction': opt_noninteraction
});
</script>
<!-- End Google Analytics -->
Run Code Online (Sandbox Code Playgroud)