AnalyticsService

显示已弃用

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

无法创建
服务
未复制

分析服务 是一组方法,可以让开发人员跟踪用户与他们的体验互动的方式,具体是玩家进度、经验经济、管道和自定义事件。

概要

方法

属性

方法

LogCustomEvent

()

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

参数

player: Player

触发事件的用户。

默认值:""
eventName: string

自定义事件的名称。

默认值:""
value: number

在聚合中使用的事件的值。

默认值:1
customFields: Dictionary

可选的自定义字段词典,可在 Roblox 提供的图表中提供分析。只有特定的键,由 Enum.AnalyticsCustomFieldKeys 提供,才会用于这些分析。每个体验的三个自定义字段的值的独特组合限制为 8,000 个。

默认值:"nil"

返回

()

代码示例

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

()

记录用于跟踪体验相关玩家操作的事件。

参数

player: Player

触发事件的用户。

默认值:""

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

默认值:""
currencyType: string

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

默认值:""
amount: number

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

默认值:""
endingBalance: number

货币添加或移除后,用户的余额。此值应始终大于或等于 0。

默认值:""
transactionType: string

发生的交易类型。虽然您可以使用任何交易输入,但建议使用 Enum.AnalyticsEconomyTransactionType 从中提供的类型,例如 "IAP""ContextualPurchase" 来启用 Roblox 工具和图表的未来洞察力。

因为该字段类型是字符串,你需要传递枚举的 Name 值。例如 Enum.AnalyticsEconomyTransactionType.IAP.Name .

每次体验限于 20 种独特类型。

默认值:""
itemSku: string

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

默认值:""
customFields: Dictionary

可选的自定义字段词典,可在 Roblox 提供的图表中提供分析。只有特定的键,由 Enum.AnalyticsCustomFieldKeys 提供,才会用于这些分析。每个体验的三个自定义字段的值的独特组合限制为 8,000 个。

默认值:"nil"

返回

()

代码示例

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

()

记录用于跟踪用户在预定的管道中步行的用户操作的事件。漏斗分析只会考虑漏斗会话的第一步中用户和事件值。

参数

player: Player

触发事件的用户。

默认值:""
funnelName: string

漏斗的名称。这应该与漏斗中的所有步骤相同。每个体验限制为 10 个独特漏斗。

默认值:""
funnelSessionId: string

可选独特标识符为漏斗会话。这应该与漏斗中的所有步骤相同。

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

默认值:""
step: number

漏斗中的步骤数。这应该是每个步骤在漏斗中唯一的。所有漏斗都从步骤 1 开始。限于步骤 1-100。

同一用户在同一个漏斗会话中重复步骤,或当 funnelSessionId 被忽略时,将忽略nil

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

默认值:1
stepName: string

漏斗中步骤的可选名称。该字段仅用于在 Roblox 提供的图表中显示目的。

默认值:""
customFields: Dictionary

可选的自定义字段词典,可在 Roblox 提供的图表中提供分析。只有特定的键,由 Enum.AnalyticsCustomFieldKeys 提供,才会用于这些分析。每个体验的三个自定义字段的值的独特组合限制为 8,000 个。

默认值:"nil"

返回

()

代码示例

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

()

记录用于跟踪用户通过启动通道步骤的用户操作的事件。漏斗分析只会考虑漏斗会话的第一步中用户和事件值。

参数

player: Player

触发事件的用户。

默认值:""
step: number

漏斗中的步骤数。这应该是每个步骤在漏斗中唯一的。所有漏斗都从步骤 1 开始。限于步骤 1-100。

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

默认值:""
stepName: string

漏斗中步骤的可选名称。该字段仅用于在 Roblox 提供的图表中显示目的。

默认值:""
customFields: Dictionary

可选的自定义字段词典,可在 Roblox 提供的图表中提供分析。只有特定的键,由 Enum.AnalyticsCustomFieldKeys 提供,才会用于这些分析。每个体验的三个自定义字段的值的独特组合限制为 8,000 个。

默认值:"nil"

返回

()

代码示例

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

()

记录用户完成等级尝试时的事件。该事件目前在任何 Roblox 提供的图表上不显示。

参数

player: Player

触发事件的玩家。

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

返回

()

LogProgressionEvent

()

记录用户开始、完成或失败等级尝试时的事件。该事件目前在任何 Roblox 提供的图表中均未显示。

参数

player: Player

触发事件的玩家。

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

返回

()

LogProgressionFailEvent

()

记录用户在等级尝试失败时发生的事件。该事件目前在任何 Roblox 提供的图表中都不显示。

参数

player: Player

触发事件的用户。

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

返回

()

LogProgressionStartEvent

()

记录用户开始等级尝试时的事件。该事件目前在任何 Roblox 提供的图表上不显示。

参数

player: Player

触发事件的玩家。

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

返回

()

活动