- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[[GANTracker sharedTracker] startTrackerWithAccountID:kAnalyticsAccountId
dispatchPeriod:kGANDispatchPeriodSec
delegate:nil];
NSError *error;
NSCalendar * calendar = [NSCalendar currentCalendar];
NSDateComponents * components = [calendar components:NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit | NSSecondCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit
fromDate:[NSDate date]];
NSString * stringTime = [NSString stringWithFormat:@"%d:%d",components.hour, components.minute];
if (![[GANTracker sharedTracker] setCustomVariableAtIndex:1
name:@"TIME"
value:stringTime
withError:&error]) {
NSLog(@"error in setCustomVariableAtIndex");
}
[self.window addSubview:navigationController.view];
[self.window makeKeyAndVisible];
return YES;
}
由于值是URL编码,因此16:30在GA站点中变为16%3A30。我想让它显示为它。是的,16:30。我该怎么做呢? 我从其他控制器设置的自定义变量也没有得到更新。 例如:
- (void)viewDidLoad {
[super viewDidLoad];
UIDevice *device = [UIDevice currentDevice];
NSError *errorMsg;
if (![[GANTracker sharedTracker] setCustomVariableAtIndex:2
name:@"DEVICE"
value:device.model
withError:&errorMsg]) {
NSLog(@"error in setCustomVariableAtIndex2");
}
}
这不会更新。我知道数据需要一天时间才能反映在网站上。但只有自定义变量(键1)才有数据。其他键显示“此视图没有数据”虽然我使用索引2(参见上面的代码)。 有人可以帮帮我吗?
答案 0 :(得分:0)
由于值是URL编码,因此16:30在GA站点中变为16%3A30。我想让它显示为它。是的,16:30。我该怎么做呢?
NSString *testme = @"16%3A30";
testme = [testme stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSLog(@"testme = %@", testme); //16:30