본문 바로가기

개발도구/iOS - 아이폰 개발

[아이폰] Google analytics 어플에 구글분석기 달기

http://www.google.com/intl/ko_ALL/analytics/
먼저 위의 사이트에서 구글 분석기에 가입을 하자

그 후에
http://code.google.com/intl/ko-KR/apis/analytics/docs/mobile/ios.html

추가 라이브러리 libsqlite3.dylib , CFNetwork.framework 을 추가 해줘야 합니다. 


#import "BasicExampleAppDelegate.h"


#import "GANTracker.h"

// Dispatch period in seconds
static const NSInteger kGANDispatchPeriodSec = 10;

@implementation BasicExampleAppDelegate

@synthesize window = window_;
// didFinishLaunchingWithOptions 와 같이 delegate가 시작하는 곳에 아래의 소스를 넣어주면 됨!
- (void)applicationDidFinishLaunching:(UIApplication *)application {
 
// **************************************************************************
 
// PLEASE REPLACE WITH YOUR ACCOUNT DETAILS.
 
// **************************************************************************
 
[[GANTracker sharedTracker] startTrackerWithAccountID:@"UA-0000000-1"
                                        dispatchPeriod
:kGANDispatchPeriodSec
                                             
delegate:nil];

 
NSError *error;
 
if (![[GANTracker sharedTracker] setCustomVariableAtIndex:1
                                                       name
:@"iPhone1"
                                                      value
:@"iv1"
                                                  withError
:&error]) {
   
// Handle error here
 
}

 
if (![[GANTracker sharedTracker] trackEvent:@"my_category"
                                       action
:@"my_action"
                                        label
:@"my_label"
                                        value
:-1
                                   withError
:&error]) {
   
// Handle error here
 
}

 
if (![[GANTracker sharedTracker] trackPageview:@"/app_entry_point"
                                   withError
:&error]) {
   
// Handle error here
 
}

 
[window_ makeKeyAndVisible];
}

- (void)dealloc {
 
[[GANTracker sharedTracker] stopTracker];
 
[window_ release];
 
[super dealloc];
}

@end

UA-00000000-1 의 값을 자신의 고유 사이트 값으로 교체를 한다.
그 값은 방금 가입했던 구글 분석기에서 제공해준다.

안드로이드는 실시간 정보를 바로 바로 확인이 가능했으나,
아이폰은 실시간을 제공하지 않은거 같다.
아무리 봐도 확인이 되지 않아. 결국 24시간 그 다음날 출근해서야 확인이 가능했다.
테스트 7회의 조회수가 나온다. 다행이다. 하하하하....

그리 어려운 부분이 아니니.. 잘 해보시길 바라며,,,
소스의 궁금한 점이 있다면,

EasyTracker Library

An EasyTracker Library is available. It provides application and UIViewController level tracking with almost no development effort. You can find it in the Downloads section of theanalytics-api-samples project.

구글에서 제공해주는 샘플소스를 다운해서 사용해보는것도 좋을듯 싶다.