iOS 谷歌分析集成
<p><p>我正在尝试将 Google Analytics 与我的 iOS 应用程序集成。我按照 Ray Wenderlich 的 <a href="http://www.raywenderlich.com/53459/google-analytics-ios" rel="noreferrer noopener nofollow">website</a> 中的教程进行操作。 .</p>
<p>我添加了 GA SDK 中的所有文件,并添加了库 CoreData、SystemConfiguration、libz.dylib、libGoogleAnalyticsServices.a 和 AdSupport。
我在我的 AppDelegate didFinishLaunchingWithOptions 中添加了这段代码:</p>
<pre><code>.trackUncaughtExceptions = YES;
.dispatchInterval = 20;
[[ logger] setLogLevel:kGAILogLevelVerbose];
[ trackerWithTrackingId:@"UA-XXXXXXX-2"];
</code></pre>
<p>我的 ViewController.h 是这样的:</p>
<pre><code>#import "GAITrackedViewController.h"
@interface GroupsViewController : GAITrackedViewController <UITableViewDataSource, UITableViewDelegate>
</code></pre>
<p>在 ViewController.m 中,我在 ViewDidAppear 中添加了这段代码并添加了#import "GAI.h":</p>
<pre><code>self.screenName = @"Test View";
</code></pre>
<p>当我在我的设备上运行应用程序时,我会收到如下响应:</p>
<pre><code>2014-11-08 11:24:45.096 MyApp 06g80YZdV4
2014-11-08 11:24:45.104 MyApp VERBOSE: GoogleAnalytics 3.10 - (GAIBatchingDispatcher.m:497): Saved hit: {
parameters = {
"&_crc" = 0;
"&_u" = ".o";
"&_v" = "mi3.1.0";
"&a" = 1319486949;
"&aid" = "com.myname.MyApp";
"&an" = "MyApp";
"&av" = "1.0";
"&cd" = "Test View";
"&cid" = "35ffca8c-66fb-4b50-b23c-bd74f9fe1351";
"&ds" = app;
"&sr" = 320x568;
"&t" = appview;
"&tid" = "UA-XXXXXXX-2";
"&ul" = nl;
"&v" = 1;
"&z" = 4204001371526698847;
gaiVersion = "3.10";
};
timestamp = "2014-11-08 10:24:45 +0000";
}
2014-11-08 11:24:45.778 MyApp Found: 3 groups
2014-11-08 11:24:50.822 MyApp VERBOSE: GoogleAnalytics 3.10 - (GAIRequestBuilder.m:167): building URLRequest for https://ssl.google-analytics.com/batch
2014-11-08 11:24:50.824 MyApp VERBOSE: GoogleAnalytics 3.10 - (GAIBatchingDispatcher.m:612): Sending hit(s) POST: https://ssl.google-analytics.com/batch
2014-11-08 11:24:51.007 MyApp INFO: GoogleAnalytics 3.10 - (GAIBatchingDispatcher.m:208): Hit(s) dispatched: HTTP status 200
2014-11-08 11:24:51.009 MyApp INFO: GoogleAnalytics 3.10 - (GAIBatchingDispatcher.m:509): hit(s) Successfully deleted
2014-11-08 11:24:51.013 MyApp INFO: GoogleAnalytics 3.10 - (GAIBatchingDispatcher.m:219): 2 hit(s) sent
</code></pre>
<p>我注意到大部分输出似乎是正确的。但我注意到输出中的“GAIBatchingDispatcher deleteHits”与教程中的不同。我的说:已成功删除,但教程输出显示已成功发送。</p>
<p>如何解决此问题,以便 Google Analytics 跟踪我的 Apps ViewController?</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>我发现了问题所在。所有编码都是正确的(尽管“成功删除”日志很奇怪)。</p>
<p>我必须在 Google Analytics(分析)中配置我的 App 属性。我创建了一个数据显示,并且必须将属性标准显示数据设置为我创建的数据显示。</p>
<p>(我的GA不是英文所以不知道Data Display的确切名称)</p>
<p>我关注了 <a href="https://developers.google.com/analytics/devguides/collection/ios/v3/" rel="noreferrer noopener nofollow">link</a>说明请不要跳到编码部分,Before you Begin 也很重要!</p></p>
<p style="font-size: 20px;">关于iOS 谷歌分析集成,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/26816153/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/26816153/
</a>
</p>
页:
[1]