分析服务 是一个可以让开发人员跟踪用户与其体验互动方式的方法收集,例如玩家进度、在体验中的经济学、隧道和自定义事件。
概要
方法
记录用户在体验中使用的自定义指标。
- LogEconomyEvent(player : Player,flowType : Enum.AnalyticsEconomyFlowType,currencyType : string,amount : number,endingBalance : number,transactionType : string,itemSku : string,customFields : Dictionary):void
记录用于跟踪玩家在体验中相关的行为的事件。
- LogFunnelStepEvent(player : Player,funnelName : string,funnelSessionId : string,step : number,stepName : string,customFields : Dictionary):void
记录用户通过预计的 funnel 步骤的行为。
- LogOnboardingFunnelStepEvent(player : Player,step : number,stepName : string,customFields : Dictionary):void
记录用户通过 onboarding funnel 的步骤。
- LogProgressionCompleteEvent(player : Player,progressionPathName : string,level : number,levelName : string,customFields : Dictionary):void
为用户完成关卡尝试时记录一个事件。
- LogProgressionEvent(player : Player,progressionPathName : string,status : Enum.AnalyticsProgressionType,level : number,levelName : string,customFields : Dictionary):void
为用户开始、完成或失败一级尝试时记录一个事件。
- LogProgressionFailEvent(player : Player,progressionPathName : string,level : number,levelName : string,customFields : Dictionary):void
为用户失败一次关卡尝试时记录一个事件。
- LogProgressionStartEvent(player : Player,progressionPathName : string,level : number,levelName : string,customFields : Dictionary):void
为用户开始等级尝试时记录一个事件。
属性
方法
LogCustomEvent
在体验中跟踪用户的自定义 метри的事件。有关更多信息,请参阅自定义事件。
参数
触发事件的用户。
自定义事件的名称。
用于聚合的事件的值。
可选的自定义字典,可以在 Roblox 提供的图表中提供分析。 只有 Enum.AnalyticsCustomFieldKeys 提供的特定钥匙才会用于这些分析。 对于每个体验的三个自定义字段的三个独特值的唯一 8,000 个独特组合。
返回
代码示例
This example uses AnalyticsService:LogCustomEvent() to log two custom events: MissionStarted and MissionCompletedDuration.
local AnalyticsService = game:GetService("AnalyticsService")
-- Log when the mission starts
AnalyticsService:LogCustomEvent(
player,
"MissionStarted" -- Custom event name
)
-- Log when the mission is completed with the time it took
AnalyticsService:LogCustomEvent(
player,
"MissionCompletedDuration", -- Custom event name
120 -- Event value used in aggregation
)
LogEconomyEvent
记录用于跟踪玩家在体验中相关的行为的事件。
参数
触发事件的用户。
应该使用 Enum.AnalyticsEconomyFlowType 指定货币的方向。
添加或移除货币的名称,例如 "gold" ,"gems" 或 "energy" 。每个体验限定 5 种货币类型。
添加或移除货币的数量。这个值总是应该是正的。
货币添加或移除后的用户余额。这个值应该总是大于或等于 0。
发生的交易类型。虽然您可以使用任何交易输入,但建议您使用<a href="https://developer.roblox.com/en/ documentation/ roblox-tools-and- charts/">Roblox工具和图形</a>提供的类型,例如<a href="https://developer.roblox.com/en/ documentation/ roblox-tools-and- charts/">“IAP”</a>或<a href="https://developer.roblox.com/en/ documentation/ roblox-tools
因为此字段类型是一个字符串,您需要通过枚举的 Name 值。例如 Enum.AnalyticsEconomyTransactionType.IAP.Name。
每个体验限于 20 个独特类型。
购买物品或包裹的可选 SKU。 这是唯一标识物品购买的标识。 每个体验限于 100 个独特 SKU。
可选的自定义字典,可以在 Roblox 提供的图表中提供分析。 只有 Enum.AnalyticsCustomFieldKeys 提供的特定钥匙才会用于这些分析。 对于每个体验的三个自定义字段的三个独特值的唯一 8,000 个独特组合。
返回
代码示例
The following sample tracks a Robux purchase of a 1000-coin bundle, using the IAP (in-app purchase) transaction type. Note the item name provided as an optional parameter when compared to the previous sample.
local AnalyticsService = game:GetService("AnalyticsService")
AnalyticsService:LogEconomyEvent(
player,
Enum.AnalyticsEconomyFlowType.Source,
"Coins",
1000, -- How many coins are in the bundle
1020, -- balance after transaction
Enum.AnalyticsEconomyTransactionType.IAP.Name,
"1000CoinBundle" -- Unique identifier of the coin bundle
)
LogFunnelStepEvent
仅记录用户使用预计计划的 funnel 迁移。 funnel 分解将仅考虑 funnel 会话中的用户和事件值。
参数
触发事件的用户。
烟囱的名称。这应该是所有步骤在烟囱中的相同。每个体验限于 10 个独特烟囱。
有选择的独特标识于有趣的会话。这应该是所有步骤在有趣的会话中的相同。
注意,此字段仅用于 递归 通道,例如购买流程通道或物品升级通道。如果您没有自然的通道会话标识,请使用 HttpService:GenerateGUID() 。
在隧道中的步骤号。这应该是每个步骤在隧道中独特的。所有隧道都从步骤 1 开始。 有限于步骤 1-100。
同一个用户在同一个 funnel 会话中重复步骤,或 when funnelSessionId 是 nil 将被忽略。
注意,如果任何步骤被跳过,中间步骤将被视为已完成。
在隧道中步骤的可选名称。此字段仅用于显示目的地,在 Roblox 提供的图形中不会使用。
可选的自定义字典,可以在 Roblox 提供的图表中提供分析。 只有 Enum.AnalyticsCustomFieldKeys 提供的特定钥匙才会用于这些分析。 对于每个体验的三个自定义字段的三个独特值的唯一 8,000 个独特组合。
返回
代码示例
The following sample tracks some basic events for each user beginning the process to buy an item from an "armory" shop. Note the funnelSessionId used to distinguish between different sessions of the same user opening the shop.
local AnalyticsService = game:GetService("AnalyticsService")
local HttpService = game:GetService("HttpService")
funnelSessionId = HttpService:GenerateGUID()
-- Log when the user opens the store
AnalyticsService:LogFunnelStepEvent(
player,
"ArmoryCheckout", -- Funnel name used to group steps together
funnelSessionId, -- Funnel session id for this unique checkout session
1, -- Step number
"Opened Store" -- Step name
)
-- Log when the user views an item
AnalyticsService:LogFunnelStepEvent(
player,
"ArmoryCheckout", -- Funnel name used to group steps together
funnelSessionId, -- Funnel session id for this unique checkout session
2, -- Step number
"Viewed Item" -- Step name
)
-- Log when the user views adds to cart
AnalyticsService:LogFunnelStepEvent(
player,
"ArmoryCheckout", -- Funnel name used to group steps together
funnelSessionId, -- Funnel session id for this unique checkout session
3, -- Step number
"Added to Cart" -- Step name
)
LogOnboardingFunnelStepEvent
记录一个用于跟踪用户行动的事件。 隧道分解将仅考虑从隧道会话的第一步开始的用户和事件值。
参数
触发事件的用户。
在隧道中的步骤号。这应该是每个步骤在隧道中独特的。所有隧道都从步骤 1 开始。 有限于步骤 1-100。
注意,如果任何步骤被跳过,中间步骤将被视为已完成。
在隧道中步骤的可选名称。此字段仅用于显示目的地,在 Roblox 提供的图形中不会使用。
可选的自定义字典,可以在 Roblox 提供的图表中提供分析。 只有 Enum.AnalyticsCustomFieldKeys 提供的特定钥匙才会用于这些分析。 对于每个体验的三个自定义字段的三个独特值的唯一 8,000 个独特组合。
返回
代码示例
The following sample demonstrates how to log two steps of an onboarding funnel. An onboarding funnel typically introduces players to the game's core loop.
local AnalyticsService = game:GetService("AnalyticsService")
-- Log the first step of the FTUE
AnalyticsService:LogOnboardingFunnelStepEvent(
player,
1, -- Step number
"Joined Game" -- Step name
)
-- Log the second step of the FTUE
AnalyticsService:LogOnboardingFunnelStepEvent(
player,
2, -- Step number
"Choose Class" -- Step name
)
LogProgressionCompleteEvent
为用户完成关卡尝试时记录一个事件。此事件目前在 Roblox 提供的任何图形中不显示。
参数
触发事件的玩家。
返回
LogProgressionEvent
为用户开始、完成或失败级别尝试时记录一个事件。 此事件目前不会在 Roblox 提供的图形中显示。
参数
触发事件的玩家。
返回
LogProgressionFailEvent
为用户失败一次关卡尝试时记录一个事件。 此事件目前在 Roblox 提供的任何图形中不显示。
参数
触发事件的用户。
返回
LogProgressionStartEvent
为用户开始等级尝试时记录一个事件。 此事件目前不会在 Roblox 提供的任何图形中显示。
参数
触发事件的玩家。