简体   繁体   English

Google Analytics不会在iPhone上正确跟踪HTML5移动应用中的事件

[英]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: 在您的网站上:

  • Are you sure your embed the Google Analytics code snippet on every page who required tracking? 您确定要在每个需要跟踪的网页上嵌入Google Analytics代码段吗?
  • Load Google analytics from the asynchronous way . 异步方式加载Google Analytics。
  • On Google analytics check on Real time > Overview. 在Google Analytics上检查实时>概述。 As full report are delayed from few hours. 由于完整报告延迟了几个小时。
  • If you url is something like httq://localhost/ then your need to add the javascript code _gaq.push(['_setDomainName', 'none']); 如果您的url类似于httq:// localhost /那么您需要添加javascript代码_gaq.push(['_setDomainName', 'none']); please read this post 请阅读这篇文章
  • It can't work with file:// url 它不能与file:// url一起使用
  • (Probably not) Check if you can download the JavaScript from Google Analytics. (可能不是)检查您是否可以从Google Analytics下载JavaScript。 Maybe your proxy block Google analytics tracking ? 也许您的代理阻止Google分析跟踪?


In your application: 在您的申请中:

  • You are using embedded HTML 5 page within your app. 您正在应用中使用嵌入式HTML 5页面。 So the way your open a page is using file://PATH_TO_MY_DIR/index.html as it's on your hard drive you can't send data to Google analytics. 因此,您打开网页使用file://PATH_TO_MY_DIR/index.html的方式就像在硬盘上一样,您无法将数据发送到Google Analytics。
  • As you are probably using PhoneGap, you need to "jump out" of your HTML page into native Objective-c code and send the event from your Objective-C code. 由于您可能正在使用PhoneGap,因此您需要将HTML页面“跳出”为本机Objective-c代码并从Objective-C代码发送事件。 Read Google Analytics and PhoneGap and this google group thread 阅读Google Analytics和PhoneGap以及此google小组帖子


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.

相关问题 使用Google Analytics(分析)跟踪通用iOS应用的事件 - Tracking events for universal iOS app with Google Analytics 如何将Google Analytics(分析)合并到具有离线/在线模式的HTML5移动应用中? - How can Google Analytics be incorporated in HTML5 Mobile App that has offline/online mode? 带有点击跟踪的Google Mobile Ads SDK应用事件 - Google Mobile Ads SDK App Events with Click Tracking 在iOS Google Analytics(分析)中跟踪“后退”按钮事件 - Tracking “Back” button events in iOS Google Analytics 如何在移动应用程序(iOS)的Google Analytics(分析)中设置具有多个视图的事件跟踪 - How to set up event tracking with multiple views in google analytics for mobile app (iOS) 将Google Analytics跟踪集成到IOS应用程序中 - Integrate Google Analytics Tracking Into IOS App 使用Google Analytics跟踪WebViews到App Profile - Tracking WebViews into App Profile with Google Analytics iOS Google Analytics(分析)未跟踪应用速度 - iOS Google analytics not tracking App speed Apple App Tracking Transparency 和 Google Analytics - Apple App Tracking Transparency and Google Analytics Google Analytics for Mobile Apps iOS SDK v3事件跟踪 - Google Analytics for Mobile Apps iOS SDK v3 event tracking
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM