Skip to content

Instantly share code, notes, and snippets.

@eggmobile
Created December 10, 2013 12:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eggmobile/7889810 to your computer and use it in GitHub Desktop.
Save eggmobile/7889810 to your computer and use it in GitHub Desktop.
iOS向けGoogle Analytics v3の設定についてメモ ref: http://qiita.com/eggmobile/items/ebffa22a1afb0d930f32
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
...
// Google アナリティクス
#import "GAI.h" //※ここを追記
#endif
// オプション: 例外を自動的にGoogle Analyticsに送る.
[GAI sharedInstance].trackUncaughtExceptions = YES;
// オプション: トラッキング間隔 20秒
[GAI sharedInstance].dispatchInterval = 20;
// オプション: よくわかんないからコメントアウトした
//[GAI sharedInstance].debug = YES;
// トラッカーのインスタンス作成
id<GAITracker> tracker = [[GAI sharedInstance] trackerWithTrackingId:@"トラッキングIDを記入"];
// GAITrackedViewController.hをインポート
#import "GAITrackedViewController.h"
//UIViewControllerのサブクラスから、GAITrackedViewControllerに変更する
@interface HogeViewController : GAITrackedViewController
//viewDidAppear:に以下の一文を追加
self.screenName = @"HogeViewController";
// インポート
#import "GAIFields.h"
#import "GAIDictionaryBuilder.h"
//viewDidLoad:に以下を追加
[[[GAI sharedInstance] defaultTracker] set:kGAIScreenName value:@"HogeTableViewController"];
[[[GAI sharedInstance] defaultTracker] send:[[GAIDictionaryBuilder createAppView] build]];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment