AnalyticsService

显示已弃用

*此内容使用人工智能(Beta)翻译,可能包含错误。若要查看英文页面,请点按 此处

无法创建
服务
未复制

分析服务 是一个可以让开发人员跟踪用户与其体验互动方式的方法收集,例如玩家进度、在体验中的经济学、隧道和自定义事件。

概要

方法

属性

方法

LogCustomEvent

void

在体验中跟踪用户的自定义 метри的事件。有关更多信息,请参阅自定义事件

参数

player: Player

触发事件的用户。

eventName: string

自定义事件的名称。

value: number

用于聚合的事件的值。

默认值:1
customFields: Dictionary

可选的自定义字典,可以在 Roblox 提供的图表中提供分析。 只有 Enum.AnalyticsCustomFieldKeys 提供的特定钥匙才会用于这些分析。 对于每个体验的三个自定义字段的三个独特值的唯一 8,000 个独特组合。

默认值:"nil"

返回

void

代码示例

This example uses AnalyticsService:LogCustomEvent() to log two custom events: MissionStarted and MissionCompletedDuration.

Log Custom Event

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

void

记录用于跟踪玩家在体验中相关的行为的事件。

参数

player: Player

触发事件的用户。

应该使用 Enum.AnalyticsEconomyFlowType 指定货币的方向。

currencyType: string

添加或移除货币的名称,例如 "gold""gems""energy" 。每个体验限定 5 种货币类型。

amount: number

添加或移除货币的数量。这个值总是应该是正的。

endingBalance: number

货币添加或移除后的用户余额。这个值应该总是大于或等于 0。

transactionType: string

发生的交易类型。虽然您可以使用任何交易输入,但建议您使用<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 个独特类型。

itemSku: string

购买物品或包裹的可选 SKU。 这是唯一标识物品购买的标识。 每个体验限于 100 个独特 SKU。

默认值:""
customFields: Dictionary

可选的自定义字典,可以在 Roblox 提供的图表中提供分析。 只有 Enum.AnalyticsCustomFieldKeys 提供的特定钥匙才会用于这些分析。 对于每个体验的三个自定义字段的三个独特值的唯一 8,000 个独特组合。

默认值:"nil"

返回

void

代码示例

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.

Tracking an in-app purchase

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

void

仅记录用户使用预计计划的 funnel 迁移。 funnel 分解将仅考虑 funnel 会话中的用户和事件值。

参数

player: Player

触发事件的用户。

funnelName: string

烟囱的名称。这应该是所有步骤在烟囱中的相同。每个体验限于 10 个独特烟囱。

funnelSessionId: string

有选择的独特标识于有趣的会话。这应该是所有步骤在有趣的会话中的相同。

注意,此字段仅用于 递归 通道,例如购买流程通道或物品升级通道。如果您没有自然的通道会话标识,请使用 HttpService:GenerateGUID()

默认值:""
step: number

在隧道中的步骤号。这应该是每个步骤在隧道中独特的。所有隧道都从步骤 1 开始。 有限于步骤 1-100。

同一个用户在同一个 funnel 会话中重复步骤,或 when funnelSessionIdnil 将被忽略。

注意,如果任何步骤被跳过,中间步骤将被视为已完成。

默认值:1
stepName: string

在隧道中步骤的可选名称。此字段仅用于显示目的地,在 Roblox 提供的图形中不会使用。

默认值:""
customFields: Dictionary

可选的自定义字典,可以在 Roblox 提供的图表中提供分析。 只有 Enum.AnalyticsCustomFieldKeys 提供的特定钥匙才会用于这些分析。 对于每个体验的三个自定义字段的三个独特值的唯一 8,000 个独特组合。

默认值:"nil"

返回

void

代码示例

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.

Tracking Shop steps

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

void

记录一个用于跟踪用户行动的事件。 隧道分解将仅考虑从隧道会话的第一步开始的用户和事件值。

参数

player: Player

触发事件的用户。

step: number

在隧道中的步骤号。这应该是每个步骤在隧道中独特的。所有隧道都从步骤 1 开始。 有限于步骤 1-100。

注意,如果任何步骤被跳过,中间步骤将被视为已完成。

stepName: string

在隧道中步骤的可选名称。此字段仅用于显示目的地,在 Roblox 提供的图形中不会使用。

默认值:""
customFields: Dictionary

可选的自定义字典,可以在 Roblox 提供的图表中提供分析。 只有 Enum.AnalyticsCustomFieldKeys 提供的特定钥匙才会用于这些分析。 对于每个体验的三个自定义字段的三个独特值的唯一 8,000 个独特组合。

默认值:"nil"

返回

void

代码示例

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.

Tracking onboarding steps

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

void

为用户完成关卡尝试时记录一个事件。此事件目前在 Roblox 提供的任何图形中不显示。

参数

player: Player

触发事件的玩家。

progressionPathName: string
level: number
levelName: string
默认值:""
customFields: Dictionary
默认值:"nil"

返回

void

LogProgressionEvent

void

为用户开始、完成或失败级别尝试时记录一个事件。 此事件目前不会在 Roblox 提供的图形中显示。

参数

player: Player

触发事件的玩家。

progressionPathName: string
level: number
levelName: string
默认值:""
customFields: Dictionary
默认值:"nil"

返回

void

LogProgressionFailEvent

void

为用户失败一次关卡尝试时记录一个事件。 此事件目前在 Roblox 提供的任何图形中不显示。

参数

player: Player

触发事件的用户。

progressionPathName: string
level: number
levelName: string
默认值:""
customFields: Dictionary
默认值:"nil"

返回

void

LogProgressionStartEvent

void

为用户开始等级尝试时记录一个事件。 此事件目前不会在 Roblox 提供的任何图形中显示。

参数

player: Player

触发事件的玩家。

progressionPathName: string
level: number
levelName: string
默认值:""
customFields: Dictionary
默认值:"nil"

返回

void

活动