0

我正在使用三个不同的范围跟踪我的应用程序中的自定义变量,如下面的代码所示。但是,当我在 Analytics 中查看我的报告时,只显示“访问者”和“会话”范围变量。页面变量似乎没有被记录(即“myCustomVariable1”和“myCustomVariable2”从未出现过。这是我第一次实现这个API,所以我一定遗漏了一些东西。

NSString *deviceModel = [[UIDevice currentDevice]model];
NSString *systemVersion = [[UIDevice currentDevice]systemVersion];

if (![[GANTracker sharedTracker] setCustomVariableAtIndex:1
                                                         name:@"DeviceModel"
                                                        value:deviceModel
                                                        scope:kGANVisitorScope 
                                                    withError:&error]) {
        NSLog(@"error in setCustomVariableAtIndex");
    }

if (![[GANTracker sharedTracker] setCustomVariableAtIndex:1
                                                         name:@"SystemVersion"
                                                        value:systemVersion
                                                        scope:kGANSessionScope 
                                                    withError:&error]) {
        NSLog(@"error in setCustomVariableAtIndex");
    }

NSString *myCustomVariable1 = @"myCustomVariable1";

if (![[GANTracker sharedTracker] setCustomVariableAtIndex:1
                                                         name:@"myCustomVariable1"
                                                        value:myCustomVariable1
                                                        scope:kGANPageScope
                                                    withError:&error]) {
        NSLog(@"error in setCustomVariableAtIndex");
    }

NSString *myCustomVariable2 = @"myCustomVariable2";


    if (![[GANTracker sharedTracker] setCustomVariableAtIndex:2
                                                         name:@"myCustomVariable2"
                                                        value:myCustomVariable2 
                                                        scope:kGANPageScope
                                                    withError:&error]) {
        NSLog(@"error in setCustomVariableAtIndex");
    }
4

0 回答 0