2013年9月2日月曜日

Google Analytics iOS SDK v2.0beta から v3.0への移行、変更点

Automatic Screen Measurement - 自動的な画面計測

// v2 -------
// SomeViewController.h
#import "GAITrackedViewController.h"
@interface SomeViewController : GAITrackedViewController
@end

// SomeViewController.m
- (void)viewDidAppear:(BOOL)animated {
  [super viewDidAppear:animated];
  self.trackedViewName = @"Some Screen";
}

// v3 -------
// change "self.trackedViewName" to "self.screenName"


Manual Screen Measurement - 手動での画面計測

// v2 -------
[[[GAI sharedInstance] defaultTracker] sendView:view]; // or trackView:view

// v3 -------
#import "GAIFields.h"
#import "GAIDictionaryBuilder.h"
[[[GAI sharedInstance] defaultTracker] set:kGAIScreenName value:view];
[[[GAI sharedInstance] defaultTracker] send:[[GAIDictionaryBuilder createAppView] build]];


Event Tracking - イベントのトラッキング

// v2 -------
[[[GAI sharedInstance] defaultTracker] sendEventWithCategory:category withAction:action withLabel:label withValue:value];

// v3 -------
#import "GAIDictionaryBuilder.h"
[[[GAI sharedInstance] defaultTracker] send:[[GAIDictionaryBuilder createEventWithCategory:category action:action label:label value:value] build]];

初期化時は[GAI sharedInstance].debugがなくなったくらい。