[英]Google Analytics not tracking events in HTML5 mobile app properly on iPhones
We are using Google Analytics to track events, but events don't appear to track 100% of the time. 我们使用Google Analytics跟踪事件,但事件似乎并非100%跟踪。 Sometimes they track, and sometimes they don't.
有时他们会跟踪,有时他们不跟踪。 We're not exceeding quota limits per session (at most we have 20 events per session).
我们没有超过每个会话的配额限制(每个会话最多我们有20个事件)。 That shouldn't be the issue.
这应该不是问题。
The tracking fails to work consistently on our normal website as well as our HTML5 mobile app version, though it's far less reliable with the HTML5 mobile app version. 跟踪无法在我们的普通网站以及我们的HTML5移动应用程序版本上保持一致,尽管HTML5移动应用程序版本的可靠性要低得多。
Code: 码:
var share_url = 'http://twitter.com/intent/tweet?text=';
// Log in GA
_gaq.push( ['_trackEvent', 'Share Twitter', ''] );
// Open URL in browser
open_external( share_url + encodeURIComponent( msg ) );
function open_external( url ) {
window.open( url + '#phonegap=external' );
}
_gaq.push( ['_trackEvent', 'Share Twitter', ''] );
This won't do anything. 这不会做任何事情。
For _trackEvent
, the third argument (where you pass an empty string) is required . 对于
_trackEvent
,第三个参数(如果你传递一个空字符串)的要求 。 It's the 'Action' parameter. 这是'Action'参数。 But an empty string is falsey, so it just fails silently.
但是空字符串是假的,所以它只是默默地失败。
Pass any value there, and it'll work. 传递任何价值,它会起作用。
Is this a reduced case? 这是一个减少的案例吗? You shouldn't be seeing any events with that code.
您不应该看到该代码的任何事件。
Are you positive that you waited long enough for the data to be processed by Google? 您是否肯定等待Google处理数据的时间足够长? Especially since some tracking seems to be working.
特别是因为一些跟踪似乎有效。 I had the same behaviour (in a mobile app btw) but after waiting for more than a day it still came through.
我有相同的行为(在移动应用程序顺便说一句)但在等待超过一天后它仍然通过。 This still occurs on a daily basis... Hope this is the case for you too.
这仍然是每天发生的......希望你也是如此。
I'm not exactly sure what your problem can be, so I will throw some idea. 我不确定你的问题是什么,所以我会提出一些想法。 Most of them are obvious but it might help.
其中大多数都很明显但可能有所帮助。
On your website: 在您的网站上:
_gaq.push(['_setDomainName', 'none']);
_gaq.push(['_setDomainName', 'none']);
please read this post
In your application: 在您的申请中:
Hope it help. 希望它有所帮助。
The problem is third parameter in: 问题是第三个参数:
_gaq.push( ['_trackEvent', 'Share Twitter', ''] );
The 2nd element of the array should be the category and the 3rd should be the action. 数组的第二个元素应该是类别,第三个元素应该是动作。 For example:
例如:
_gaq.push( ['_trackEvent', 'Share', 'Twitter'] );
You can verify this yourself by pasting each of the above into your developer console (F12 in Chrome, Ctrl-Shift-K in Firefox) and watching the network traffic. 您可以通过将上述每个内容粘贴到开发人员控制台(Chrome中的F12,Firefox中的Ctrl-Shift-K)并观察网络流量来自行验证。
Reference: 参考:
https://developers.google.com/analytics/devguides/collection/gajs/methods/gaJSApiEventTracking https://developers.google.com/analytics/devguides/collection/gajs/methods/gaJSApiEventTracking
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.