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

在ios上使用Google analytics

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

射频卡工作原理

系统属于近耦合射频识别系统,主要由应答器、阅读器、通讯模块、人机接口等几部分组成。 应答器也称邻近卡PICC(Proximity Card),是射频识别系统真正的数据载体,即我们通常所说的卡片。应答器由耦合元件以及微电子芯片组成。在阅读器的响应范围之外,应答器处于无源状态。通常,应答器没有自己供…

c++运算符优先级

1 :: 左 2 . -˃ [] () 左 3 ++ -- ~ ! - + & * () sizeof new delete castname_cast 单目操作符 右 ...…

Android NDK生成共享库和静态库

 Date: 2014-03-14Title: Compile Android Native Binary And Library Published: true...…

WinCE5.0开发环境的建立

本文主要介绍WinCE5.0开发环境的建立过程及注意事项。        …

firefox 缓存文件查看

firefox 缓存文件查看…

Android Java包各种功能概览

熟悉Android操作系统的朋友都知道,开发Android应用程序基本上使用的都是Java语言。那么要想灵活的应用这一系统,就应当熟悉其中的Android Java包的各种功能。一般的JAVA应用中,如果需用引用基础类库,通常需要使用如下的方式:import javax.swing.*;&…

发表评论

访客

看不清,换一张

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