当前位置:首页 > 编程开发

在ios上使用Google analytics

webgou14年前 (2012-08-22)编程开发1632
在ios上使用Google analytics,今天简单地测试了一下,总结: Google analytics使用分为普通web(移动web),及app(包括移动app).ios app访问记录,需要几个库: (libGoogleAnalytics.a,CFNetwork,libsqlite3.0.dylib) 下面是谷歌官网提供的操作步骤: 1。 Open Xcode and create a new iPhone OS project. 2。 Drag GANTracker.h and libGoogleAnalytics.a from the SDK's Library directory into your new project. 3。 Include the CFNetwork framework in your project and link against libsqlite3.0.dylib. 测试结果: [IMG=400,300,title]zb_users/upload/legacy-upload/2012/8/QQ20120821-1.png[/IMG] 以及经测试过的源码: [CODE_LITE] // // ViewController.h // anyltics // // Created by sunkey on 12-8-21. // Copyright (c) 2012年 sunkey. All rights reserved. // #import @interface ViewController : UIViewController @end #import "ViewController.h" #import "GANTracker.h" static NSString* const kAnalyticsAccountId = @"UA-xxxxxxxx-1"; static const NSInteger kGANDispatchPeriodSec = 10; @interface ViewController () @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. [[GANTracker sharedTracker] startTrackerWithAccountID:kAnalyticsAccountId dispatchPeriod:kGANDispatchPeriodSec delegate:nil]; NSError *error; if (![[GANTracker sharedTracker] setCustomVariableAtIndex:1 name:@"iOS1" value:@"iv1" withError:&error]) { NSLog(@"error in setCustomVariableAtIndex"); } if (![[GANTracker sharedTracker] trackEvent:@"Application iOS" action:@"Launch iOS" label:@"Example iOS" value:99 withError:&error]) { NSLog(@"error in trackEvent"); } if (![[GANTracker sharedTracker] trackPageview:@"/app_entry_point" withError:&error]) { NSLog(@"error in trackPageview"); } NSLog(@"load\n"); } - (void)viewDidUnload { [super viewDidUnload]; // Release any retained subviews of the main view. NSLog(@"unload \n"); //[[GANTracker sharedTracker] stopTracker]; } - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) { return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown); } else { return YES; } } @end [/CODE_LITE] 参考:Google Analytics SDK for iOS

扫描二维码推送至手机访问。

版权声明:本文由知了博客发布,如需转载请注明出处。

本文链接:https://www.webgou.info/?id=524

分享给朋友:

“在ios上使用Google analytics ” 的相关文章

CocoaAsyncSocket学习

CocoaAsyncSocket支持tcp和udp。其中: AsyncSocket类是支持TCP的 AsyncUdpSocket是支持UDP的AsyncSocket是封装了CFSocket和CFSteam的TCP/IP socket网络库。它提供了异步操作,本地cocoa类的基于dele…

ubuntu 11.04 电信更新源

使用root 权限:sudo su 进入编辑:gedit sources.list:…

透明位图显示

想到透明位图,找了找资料,有几种实现,并理解了下,掩码机制(其实就是数据的逻辑操作)。 …

2410 Wince Eboot 流程

 2410 Wince Eboot 流程 对于嵌入式系统来说,一般都需要一个bootloader来下载和引导操作系统,常用的bootloader有eboot,uboot以及vivi等,对于windows ce来说最理想的bootloader当然是eboot(我也做了利用uboot下载和引导…

win7下搭建pomelo方法

 笔者在win7(64位)下搭建pomelo尝尽苦头,网上说的vs2010. node 0.10.x几都试过了,没有成功,只能一步一步的尝试,终于功德圆满,不敢独享,共用之。 ...…

存储与地址映射技术

wince存储与地址映射技术…

发表评论

访客

看不清,换一张

◎欢迎参与讨论,请在这里发表您的看法和观点。