gpt4 book ai didi

ios - 谷歌分析 : tracking a custom dimension on iOS?

转载 作者:行者123 更新时间:2023-11-29 01:50:03 25 4
gpt4 key购买 nike

我在 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);
}
}

关于ios - 谷歌分析 : tracking a custom dimension on iOS?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31512128/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com