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

在ios上使用Google analytics

webgou14年前 (2012-08-22)编程开发1840
在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 ” 的相关文章

[转]Apktool(1)——Apktool的安装

 来源:https://www.cnblogs.com/mliangchen/p/5079783.htmlApktool(1)——Apktool的安装...…

iOS vs Android

iOS vs Android…

10条基本的工作要点

  刚刚走上社会的年轻人,充满了蓄势待发的豪情、青春的朝气、前卫的思想,梦想着丰富的待遇和轰轰烈烈的事业。可是,社会毕竟是一所包罗万象、喧嚣复杂的大学校,这里没有寒暑假,拒绝虚假和肤浅,更拒绝空想和庸碌,难以预告何时开课何时放学。 如何在涉世之初少走弯路,有一个好的开头。好好地遵循、把…

使用Nginx实现根据 IP 匹配指定 URL

 最近的一个项目,需要特定的IP访问某专题页面的时候跳转到网站首页,思考了下,直接使用NGINX实现,分享给大家。业务需求...…

vs快捷键大全

快捷键 功能 CTRL + SHIFT + B生成解决方案 ...…

信息加工

什么是信息加工 信息加工是对收集来的信息进行去伪存真、去粗取精、由表及里、由此及彼的加工过程。它是在原始信息的基础上,生产出价值含量高、方便用户利用的二次信息的活动过程。这一过程将使信息增值。只有在对信息进行适当处理的基础上,才能产生新的、用以指导决策的有效信息或知识。 信息加工的内容…

发表评论

访客

看不清,换一张

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