iOS Google Analytics自定义维度

Miq*_*uel 9 android google-analytics ios

我一直在阅读iOSCustom 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]];
Run Code Online (Sandbox Code Playgroud)

但是当在控制面板中创建维度时,建议的代码是:

NSString *dimensionValue = @"SOME_DIMENSION_VALUE";
[tracker set:[GAIFields customDimensionForIndex:1] value:dimensionValue];
Run Code Online (Sandbox Code Playgroud)

我也一直在阅读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()
);
Run Code Online (Sandbox Code Playgroud)

我的问题:

  • 在iOS中设置尺寸的正确方法是什么?
  • 如果是第一个(文档一),为什么在iOS中我们需要在跟踪器和构建器中设置值?
  • 为什么在iOS中,跟踪器中的维度值("高级用户")在构建器中设置为不同的值("高级")?
  • 在跟踪器和构建器中设置相同的值是否正确?
  • 在那种情况下,为什么要设置两次?我试图在构建器中设置它,然后它因错误而崩溃,这个类不是键和cd1的键值编码兼容.在跟踪器中设置它将不支持该值(iOS和自定义维度的GA).

代码可以是:

[tracker set:[GAIFields customDimensionForIndex:1]
       value:@"custom dimension value"]

[tracker send:[[[GAIDictionaryBuilder createAppView] set:@"custom dimension value"
                                                  forKey:[GAIFields customDimensionForIndex:1]] 
Run Code Online (Sandbox Code Playgroud)

小智 3

有一个很好的教程,介绍如何使用 iOS 和 Android 的自定义维度以及如何设置自定义报告。

对于第一种情况,有两种不同的方法。它们彼此独立。

第一的:

id<GAITracker> tracker = [[GAI sharedInstance] defaultTracker];
[tracker set:[GAIFields customDimensionForIndex:index] value:@"value"];
tracker send:[[GAIDictionaryBuilder createScreenView] build]];
Run Code Online (Sandbox Code Playgroud)

第二:

id<GAITracker> tracker = [[GAI sharedInstance] defaultTracker];
[tracker send:[[[GAIDictionaryBuilder createScreenView] set:@"value"
                                                     forKey:[GAIFields customDimensionForIndex:index]] build]];
Run Code Online (Sandbox Code Playgroud)

如果您想跟踪自定义维度或自定义指标,则必须在GA 管理页面上创建它们。这里选择自定义。之后,在自定义选项卡上创建自定义报告,该报告将代表您的测量结果。

重要的是,您必须在谷歌分析注册后等待一两天,直到测量结果出现在您的自定义报告中。