我正在开发一个 iPad 应用程序,该应用程序用于使用 Flicker API 搜索照片,带有 XCode 4.5 和 iOS 6.0
我只需遵循 Google-Analytics-SDK 1.5.1 for iOS 提供的指南,添加GANTracker.h和libGoogleAnalytics.a并在 iPad Simulator 6.0 上运行我的应用程序。
我在AppDelegate.m中编写了以下代码
#import "AppDelegate.h"
static NSString *const kAnalyticsAccountId = @"UA-35865309-1";
static const NSInteger kDispatchPeriodSeconds = 10;
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions: (NSDictionary *)launchOptions
{
[[GANTracker sharedTracker] startTrackerWithAccountID:kAnalyticsAccountId
dispatchPeriod:kDispatchPeriodSeconds
delegate:self];
[[GANTracker sharedTracker] setDebug:YES];
[[GANTracker sharedTracker] setDryRun:NO];
[[GANTracker sharedTracker] setSampleRate:100];
[[GANTracker sharedTracker] setAnonymizeIp:YES];
NSError *error = nil;
if (![[GANTracker sharedTracker] setCustomVariableAtIndex:1
name:@"iOS Application"
value:@"Demo Flicker"
withError:&error]) {
NSLog(@"Set Custom Variable At Index failed :: %@",error);
}
else {}
if (![[GANTracker sharedTracker] trackEvent:@"APP Launching"
action:@"No Action"
label:@"didFinishLaunchingWithOptions"
value:-1
withError:&error]) {
NSLog(@"Track event failed :: %@",error);
}
if (![[GANTracker sharedTracker] trackPageview:@"/app_entry_point"
withError:&error]) {
NSLog(@"Track page view failed :: %@",error);
}
return YES;
}
#pragma mark -
#pragma mark - GANTrackerDelegate Methods
-(void) hitDispatched:(NSString *)hitString {
NSLog(@"Hit Dispatched: %@", hitString);
}
-(void) trackerDispatchDidComplete:(GANTracker *)tracker eventsDispatched:(NSUInteger)hitsDispatched eventsFailedDispatch:(NSUInteger)hitsFailedDispatch {
NSLog(@"Dispatch completed (%u OK, %u failed)",hitsDispatched, hitsFailedDispatch);
}
在 iPad Simulator 6.0 上运行应用程序后,控制台会打印以下内容:
2012-10-26 00:21:26.835 DemoFlicker[737:11303] dispatch called
2012-10-26 00:21:26.836 DemoFlicker[737:11303] dispatching 1 hits
2012-10-26 00:21:26.836 DemoFlicker[737:11303] GET /__utm.gif? utmwv=4.9.1mi&utmn=1254389404&utmt=event&utme=5(Photo%20Search*Searching*textFieldShouldReturn)&utmcs=UTF-8&utmsr=768x1024&utmsc=24-bit&utmul=en-us&utmac=UA-35865309-1&utmp=%2FHome%20Page&utmcc=__utma%3D1.1252676167.1351163416.1351235761.1351236010.8%3B&aip=1&utmht=1351236076832&utmqt=10004 HTTP/1.1
Host: www.google-analytics.com
User-Agent: GoogleAnalytics/1.5.1 (iPad Simulator; U; CPU iPhone OS 6.0 like Mac OS X; en-us)
2012-10-26 00:21:27.004 DemoFlicker[737:11303] Hit Dispatched: /__utm.gif?utmwv=4.9.1mi&utmn=1254389404&utmt=event&utme=5(Photo%20Search*Searching*textFieldShouldReturn)&utmcs=UTF-8&utmsr=768x1024&utmsc=24-bit&utmul=en-us&utmac=UA-35865309-1&utmp=%2FHome%20Page&utmcc=__utma%3D1.1252676167.1351163416.1351235761.1351236010.8%3B&aip=1&utmht=1351236076832&utmqt=10004
2012-10-26 00:21:27.005 DemoFlicker[737:11303] Dispatch completed (1 OK, 0 failed)
2012-10-26 00:21:36.835 DemoFlicker[737:11303] dispatch called
2012-10-26 00:21:36.836 DemoFlicker[737:11303] ...nothing to dispatch
2012-10-26 00:21:48.757 DemoFlicker[737:12303] Found 10 photos matching Flower
现在,问题在于主机 www.google.com/analytics 上跟踪数据的传播。实际上我在 www.google.com/analytics 上看不到跟踪数据。
我在哪里做错了?