私はGoogleアナリティクスを実装しようとしています..皆さん、私を助けてもらえますか
-(void) setGoogleAnalytics{
// Initialize tracker.
self.tracker = [[GAI sharedInstance] trackerWithName:@"ipad app"
trackingId:kTrackingID];
NSDictionary *appDefaults = @{kAllowTracking: @(YES)};
[[NSUserDefaults standardUserDefaults] registerDefaults:appDefaults];
// User must be able to opt out of tracking
[GAI sharedInstance].optOut =
![[NSUserDefaults standardUserDefaults] boolForKey:kAllowTracking];
// Optional: automatically send uncaught exceptions to Google Analytics.
[GAI sharedInstance].trackUncaughtExceptions = YES;
// Optional: set Google Analytics dispatch interval to e.g. 20 seconds.
[GAI sharedInstance].dispatchInterval = 5;
// Optional: set Logger to VERBOSE for debug information.
[[[GAI sharedInstance] logger] setLogLevel:kGAILogLevelVerbose];
[[GAI sharedInstance] setTrackUncaughtExceptions:YES];
}
そしてそれを呼び出す
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
[self setGoogleAnalytics];
//
//
//
}
My ViewController 実装の内部
[self dispatchEvent:@"Purchase Done"];
[self trackViewName:NSStringFromClass([self class])];
-(void) trackViewName:(NSString *) strClassName{
[[GAI sharedInstance] defaultTracker];
self.screenName=[NSString stringWithFormat:@"%@",strClassName];
[self.tracker send:[[NSDictionary alloc] initWithObjectsAndKeys:strClassName,@"ViewName", nil]];
[[GAI sharedInstance] dispatch];
}
- (void)dispatchEvent:(NSString *)strButtonText{
id<GAITracker> tracker = [[GAI sharedInstance] defaultTracker];
[tracker send:[[GAIDictionaryBuilder createEventWithCategory:@"ui_action" // Event category (required)
action:@"button_press" // Event action (required)
label:strButtonText // Event label
value:nil] build]]; // Event value = [[GAI sharedInstance] defaultTracker];
[[GAI sharedInstance] dispatch];
}
Google アナリティクスのどのバージョンをダウンロードする必要がありますか?ベータ版 GoogleAnalyticsiOS_2.0beta4.zip を使用したくないため、Google GoogleAnalyticsServicesiOS_3.01.zip (推奨) をダウンロードしました