0
- (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(请参阅上面的代码)。有人可以帮我吗?

4

1 回答 1

0

由于这些值是 URL 编码的,因此 16:30 在 GA 站点中变为 16%3A30。我希望它按原样显示。即,16:30。我该怎么做呢?

NSString *testme = @"16%3A30";
testme = [testme stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSLog(@"testme = %@", testme); //16:30
于 2012-07-18T07:36:40.900 回答