设置谷歌通用分析
设置谷歌通用分析
本主题介绍如何使用云眼特性标帜(Feature Flag)AB实验测试信息丰富 Google 通用分析。
❗️
警告
本文介绍的是 Google 通用分析媒体资源,该媒体资源将于 1 年 2023 月 <> 日停止处理数据。
在此处查看有关 云眼 功能实验和 Google Analytics 4 的更新文档。
借助 Google Analytics,可以使用事件来跟踪云眼特性标帜(Feature Flag)AB实验测试激活情况,并为实验中的每个变体构建细分。有关替代解决方案的更多详细信息,请继续阅读。
下面每个部分中的示例代码演示如何将激活侦听器关闭添加到通知中心。调用回调时,代码会创建并发送一个包含实验键和变体键的事件。
要设置谷歌分析:
- 阅读有关平台的非交互事件的设置说明和信息,并研究示例代码。
- 为测试的每个变体构建细分。在区段生成器用户界面中,查看“高级”下的内容并添加新条件。选择按事件操作和事件标签筛选用户,输入区段的名称,然后保存。
- 生成您感兴趣的指标的报告。
比较结果
在比较 云眼 功能实验和 Google Analytics(分析)结果时,请记住在 Google Analytics(分析)中应用日期过滤器,以与运行 云眼 功能实验测试的日期相对应。
替代解决方案
Google 提供自定义维度作为在报告中添加非标准数据的另一种方式。自定义维度是旧版 Google Analytics(分析)中自定义变量的替代品。
云眼特性标帜(Feature Flag)建议的集成不使用自定义维度,因为免费的Google Analytics帐户仅限于20个索引(或插槽),而360个帐户限制为200个索引。由于自定义维度无法存储超过 150 字节的值,因此需要为每个云眼特性标帜(Feature Flag)AB实验测试指定一个索引。Google 建议不要重复使用索引,因此可用索引的数量是 云眼 功能实验测试的上限,可以使用自定义维度来跟踪和细分。
Android
如果正在入门,请阅读Google Analytics(分析)Android设置说明。
如需详细了解非互动事件及其支持,请参阅 Google Analytics Android SDK。
Android
import com.google.android.gms.analytics.GoogleAnalytics;
import com.google.android.gms.analytics.HitBuilders;
import com.google.android.gms.analytics.Tracker;
import com.eyeofcloud.ab.config.Experiment;
import com.eyeofcloud.ab.config.Variation;
import com.eyeofcloud.ab.notification.ActivateNotificationListener;
import com.eyeofcloud.ab.notification.NotificationCenter;
import com.eyeofcloud.ab.notification.TrackNotificationListener;
// Add a Activate listener int notificationId = eyeofcloud.notificationCenter.addNotificationListener(NotificationCenter.NotificationType.Activate, new ActivateNotificationListener() {
@Override
public void onActivate(@Nonnull Experiment experiment, @Nonnull String userId, @Nonnull Map<String, String> attributes, @Nonnull Variation variation, @Nonnull LogEvent event) {
String experimentKey = experiment.getKey();
String variationKey = variation.getKey();
// Google Analytics tracker
SampleApp application = (SampleApp) getApplication();
mTracker = application.getDefaultTracker();
// Build and send a non-interaction Event
mTracker.send(new HitBuilders.EventBuilder()
.setCategory("Eyeofcloud")
.setAction("Experiment - " + experimentKey)
.setLabel("Variation - " + variationKey)
.setNonInteraction(true) .build()
);
}
});
JavaScript
如果正在入门,请阅读Google Analytics JavaScript设置说明。
在 Google Analytics JavaScript SDK 中阅读有关非交互事件及其支持的更多信息。
JavaScript
const eyeofcloud = require('@eyeofcloud/eyeofcloud-sdk');
const eyeofcloudEnums = require('@eyeofcloud/eyeofcloud-sdk/lib/utils/enums');
/**
* Assume the Google Analytics is loaded.
* Add an ACTIVATE notification listener.
*/
const activateId = eoc.notificationCenter.addNotificationListener(
eyeofcloudEnums.NOTIFICATION_TYPES.ACTIVATE,
function onActivate(activateObject) {
const action = 'Experiment - ' + activateObject.experiment['key'];
const label = 'Variation - ' + activateObject.variation['key'];
ga(
'send', 'event', '云眼', action, label, {
nonInteraction: true,
}
);
},
);
Objective-C 和 Swift
如果正在开始使用,请阅读适用于您平台的 Google 说明:
🚧 重要
Google Analytics iOS SDK 不支持非交互事件。这可能会影响跳出率。
不支持的平台
云眼特性标帜(Feature Flag)没有建议的解决方案,用于将Google Analytics与我们的SDK集成,用于以下平台:
- 代理
- 去
- 节点
- .PHP
- Python
- Rubby