2015-07-20 83 views
0

我在使用iOS上的Google Analytics自定义维度时遇到了一些问题。 我已经在GA的Web界面中设置了我的自定义维度。但是,如果我在GA跟踪器初始化的AppDelegate中发送自定义维度,它不会像预期的那样显示。Google Analytics(分析):跟踪iOS上的自定义维度?

id tracker = [[GAI sharedInstance] defaultTracker]; 
[tracker set:[GAIFields customDimensionForIndex:1] value:@"testValue"]; 
[tracker send:[[[GAIDictionaryBuilder createAppView] set:@"testValue" forKey:[GAIFields customDimensionForIndex:1]] build]]; 

有没有人遇到过类似的问题?

回答

1
> I hope it's help you. 
// Call this on didFinishLaunchingWithOptions 

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{ 
    [self startGoogleAnalyticsTracking]; 
    [self performSelector:@selector(sendGoogleAnalyticsStartup)  withObject:nil afterDelay:3]; 
     // --------- Enter your code here 
----------// 
return YES; 
} 

- (void)startGoogleAnalyticsTracking { 
    @try { 
//  self.googleAnalyticsTracker = [[GAI sharedInstance] trackerWithTrackingId:”PASTE YOUR TRACKING ID HERE”]; 
     // Optional: automatically send uncaught exceptions to Google Analytics. 
     [GAI sharedInstance].trackUncaughtExceptions = YES; 
     // Optional: set Google Analytics dispatch interval to e.g. 20 seconds. 
     [GAI sharedInstance].dispatchInterval = 10; 
     // Optional: set debug to YES for extra debugging information. 
     [GAI sharedInstance].debug = YES; 

     // **** REPLACE Tracking Id with your own GA Tracking Id **** // 
     // Create tracker instance.Tracking Id 
     id<GAITracker> tracker = [[GAI sharedInstance] trackerWithTrackingId:@"Tracking Id"]; 
     [tracker sendView:@"Application Loaded"]; 
    }@catch (NSException *exception) { 
     NSLog(@"exception:%@",exception); 
    } 
} 



- (void)sendGoogleAnalyticsStartup { 
     @try { 
      [self.googleAnalyticsTracker sendEventWithCategory:@"Application Events" withAction:nil withLabel:@"Tracking Starts" withValue:nil]; 
     }@catch (NSException *exception) { 
      NSLog(@"exception=%@",exception); 
     } 
    } 


- (void)stopGoogleAnalyticsTracking { 
     @try { 
      [self.googleAnalyticsTracker sendEventWithCategory:@"Application Events" withAction:nil withLabel:@"Tracking Suspended /Stopped" withValue:nil]; 
     }@catch (NSException *exception) { 
      NSLog(@"exception=%@",exception); 
     } 
    } 
+0

谢谢你的快速回答,但我已经找到了“问题”,这不是一个真正的问题。我确实设置了一切。但Google Analytics需要一些时间来分析数据。它需要很长的时间才会出现在Web界面中,因此对于每个遇到类似问题的人:耐心等待! – OutOfBounds

+0

它没有问题 –

0

我发现“问题”不是真的。我确实设置了一切。但Google Analytics需要一些时间来评估数据。在Web界面显示之前,它需要很长的时间(48小时以上)。因此对于每个遇到类似问题的人:耐心等待!

相关问题