[英]Google Analytics: tracking a custom dimension on iOS?
關於iOS上的Google Analytics(分析)的自定義維度,我遇到了一些問題。 我已經在GA的網絡界面中設置了自定義維度。 但是,如果我在GA跟蹤器初始化時在AppDelegate中發送我的自定義維度,則它不會像預期的那樣顯示。
id tracker = [[GAI sharedInstance] defaultTracker];
[tracker set:[GAIFields customDimensionForIndex:1] value:@"testValue"];
[tracker send:[[[GAIDictionaryBuilder createAppView] set:@"testValue" forKey:[GAIFields customDimensionForIndex:1]] build]];
有人遇到類似的問題嗎?
> 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);
}
}
我發現“問題”並不是一個真正的問題。 我確實正確設置了所有內容。 但是Google Analytics(分析)需要一些時間來評估數據。 它需要很長時間(48hrs +)才能顯示在網絡界面中。 因此,對於遇到類似問題的每個人,請耐心等待!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.