[英]iOS Google Analytics Custom Dimensions
I've been reading the Custom Dimensions documentation for iOS and found the following example: 我一直在阅读iOS的Custom Dimensions文档,并找到了以下示例:
// May return nil if a tracker has not yet been initialized with a property ID.
id tracker = [[GAI sharedInstance] defaultTracker];
// Set the custom dimension value on the tracker using its index.
[tracker set:[GAIFields customDimensionForIndex:1]
value:@"Premium user"]
[tracker set:kGAIScreenName
value:@"Home screen"];
// Send the custom dimension value with a screen view.
// Note that the value only needs to be sent once, so it is set on the Map,
// not the tracker.
[tracker send:[[[GAIDictionaryBuilder createAppView] set:@"premium"
forKey:[GAIFields customDimensionForIndex:1]] build]];
But when the dimension is created in control panel, the proposed code is: 但是当在控制面板中创建维度时,建议的代码是:
NSString *dimensionValue = @"SOME_DIMENSION_VALUE";
[tracker set:[GAIFields customDimensionForIndex:1] value:dimensionValue];
I've been also reading the documentation for Android and found this example: 我也一直在阅读Android的文档,并找到了这个例子:
// Get tracker.
Tracker t = ((AnalyticsSampleApp) getActivity().getApplication()).getTracker(TrackerName.APP_TRACKER);
t.setScreen("Home Screen");
// Send the custom dimension value with a screen view.
// Note that the value only needs to be sent once.
t.send(new HitBuilders.AppViewBuilder()
.setCustomDimension(1, "premiumUser")
.build()
);
My questions: 我的问题:
The code could be: 代码可以是:
[tracker set:[GAIFields customDimensionForIndex:1]
value:@"custom dimension value"]
[tracker send:[[[GAIDictionaryBuilder createAppView] set:@"custom dimension value"
forKey:[GAIFields customDimensionForIndex:1]]
There is a good tutorial how to use custom dimensions both iOS and Android and how to set custom reports. 有一个很好的教程如何使用iOS和Android的自定义维度以及如何设置自定义报告。
In the case of the first one there are two different ways. 在第一种情况下,有两种不同的方式。 They are independent from each other.
它们彼此独立。
First: 第一:
id<GAITracker> tracker = [[GAI sharedInstance] defaultTracker];
[tracker set:[GAIFields customDimensionForIndex:index] value:@"value"];
tracker send:[[GAIDictionaryBuilder createScreenView] build]];
Second: 第二:
id<GAITracker> tracker = [[GAI sharedInstance] defaultTracker];
[tracker send:[[[GAIDictionaryBuilder createScreenView] set:@"value"
forKey:[GAIFields customDimensionForIndex:index]] build]];
If you want track custom dimensions or custom metric, then you have to create them on the GA adminpage . 如果您想要跟踪自定义维度或自定义指标,则必须在GA管理页面上创建它们。 Here choose custom definitions.
在这里选择自定义。 After that create a custom report on the customization tab, which will represent your measurements.
之后,在自定义选项卡上创建自定义报告,该报告将代表您的测量结果。
Important that you have to wait maybe one or two days after the google analytics registration until measurements will appear in your custom reports. 重要的是,您必须等待谷歌分析注册后一两天,直到测量结果出现在您的自定义报告中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.