2.在http://code.google.com/intl/zh-CN/mobile/analytics/docs/iphone/中下载ios 的google跟踪SDK
3.在工程的delegate文件的 applicationDidFinishLaun
#import "GANTracker.h"
[[GANTracker sharedTracker] startTrackerWithAccountID:@"UA-15609865-3" dispatchPeriod:10 delegate:nil];
startTrackerWithAccountID:google申请账号里面的那个webprofile文件的唯一标示
dispatchPeriod :表示多少秒之后用户的行为数据传给google
4. 页面跟踪
NSError *error;
if (![[GANTracker sharedTracker] trackPageview:@"/app_launched" withError:&error]) { // Handle error here }
上述代码可以加在你代码中的任何位置,比如initwithFrame等初始化方法中,不过得包含头文件#import "GANTracker.h"
5.事件跟踪:
- (IBAction) saveTheWorld:(id) sender {
NSError *error; if (![[GANTracker sharedTracker] trackEvent:@"button_click" action:@"save_the_world" label:@"my_label" value:-1 withError:&error]) { // Handle error here } }
参考网站:
http://www.icodeblog.com/2010/04/22/how-to-integrate-google-analytics-tracking-into-your-apps-in-7-minutes/
http://code.google.com/intl/zh-CN/mobile/analytics/docs/iphone/