多个帐户的Google Analytics(分析)事件跟踪不起作用 [英] Google analytics event tracking on Multiple accounts not working

查看:58
本文介绍了多个帐户的Google Analytics(分析)事件跟踪不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在某些页面上有多个帐户-我正在尝试跟踪一些事件-当我在Fiddler上对其进行测试时它们会漂亮地触发-但它们没有进入我的分析-代码在下面-我在做什么错?三天后,任何帮助将是巨大的.

I have multiple accounts on some pages - I am trying to track some events - they fire beautifully when I test them on Fiddler - but they are not coming into my analytics - the code is below - what am I doing wrong? Three days later any help would be GREAT.

<script type="text/javascript"> 
    var _gaq = _gaq || [];

    _gaq.push(
        //tracking for first
        ['_setAccount', 'UA-XXXXXX-1'],
        ['_trackPageview'],

        //tracking for second
        ['b._setAccount', 'UA-XXXXXX-16'],
        ['b._trackPageview'],
        ['b._trackEvent'],
        ['b._trackPageLoadTime']
    );

    (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'; 
        (document.getElementsByTagName('head')[0] ||
        document.getElementsByTagName('body')[0]).appendChild(ga); 
    })();
</script>

<li><a href="#anchor_2" class="gray"
onClick="_gaq.push(['b._trackEvent', 'button3', 'menu', 'clicked']);">link</a></li>

推荐答案

请注意,现在不推荐使用_trackPageLoadTime.您不再需要了.同样,最上面的事件也没有意义.事件必须至少具有两个字符串参数,并且它们具有可选的第3个字符串参数和第4个整数参数.

Note that _trackPageLoadTime is deprecated now. You don't need that anymore. Also the event on the top doesn't make sense. Events must have at least two string parameters and they have optional 3rd string parameter and 4th integer parameter.

因此,您顶部的代码应如下所示:

So your code on the top should look like this:

 var _gaq = _gaq || []; 
_gaq.push(
  //tracking for first
  ['_setAccount', 'UA-XXXXXX-1'],
  ['_trackPageview'],
  //tracking for second
  ['b._setAccount', 'UA-XXXXXX-16'],
  ['b._trackPageview']

然后,当您触发事件时,您只会将此事件发送到您的b帐户,我相信您希望同时发送给这两个帐户.因此,出于这个原因,您应该执行以下操作:

Then when you're firing the event you are only sending this to your b account and I believe you want to send to both. So for that reason you should do something like this:

<li><a href="#anchor_2" class="gray" onClick="_gaq.push(['_trackEvent', 'button3', 'menu', 'clicked']);_gaq.push(['b._trackEvent', 'button3', 'menu', 'clicked']);">take me somewhere</a></li>

这篇关于多个帐户的Google Analytics(分析)事件跟踪不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆