学习
引擎类
AnalyticsService
无法创建
服务
未复制

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


概要
属性
ApiKey:string
已弃用
方法
FireCustomEvent(player: Instance,eventCategory: string,customData: Variant):()
已弃用
FireEvent(category: string,value: Variant):()
已弃用
FireInGameEconomyEvent(player: Instance,itemName: string,economyAction: Enum.AnalyticsEconomyAction,itemCategory: string,amount: number,currency: string,location: Variant,customData: Variant):()
已弃用
FireLogEvent(player: Instance,logLevel: Enum.AnalyticsLogLevel,message: string,debugInfo: Variant,customData: Variant):()
已弃用
FirePlayerProgressionEvent(player: Instance,category: string,progressionStatus: Enum.AnalyticsProgressionStatus,location: Variant,statistics: Variant,customData: Variant):()
已弃用
LogCustomEvent(player: Player,eventName: string,value: number,customFields: Dictionary):()
LogEconomyEvent(player: Player,flowType: Enum.AnalyticsEconomyFlowType,currencyType: string,amount: number,endingBalance: number,transactionType: string,itemSku: string,customFields: Dictionary):()
LogFunnelStepEvent(player: Player,funnelName: string,funnelSessionId: string,step: number,stepName: string,customFields: Dictionary):()
LogOnboardingFunnelStepEvent(player: Player,step: number,stepName: string,customFields: Dictionary):()
LogProgressionCompleteEvent(player: Player,progressionPathName: string,level: number,levelName: string,customFields: Dictionary):()
LogProgressionEvent(player: Player,progressionPathName: string,status: Enum.AnalyticsProgressionType,level: number,levelName: string,customFields: Dictionary):()
LogProgressionFailEvent(player: Player,progressionPathName: string,level: number,levelName: string,customFields: Dictionary):()
LogProgressionStartEvent(player: Player,progressionPathName: string,level: number,levelName: string,customFields: Dictionary):()
继承成员

API 参考
属性
ApiKey
已弃用

方法
FireCustomEvent
已弃用

FireEvent
已弃用

FireInGameEconomyEvent
已弃用

FireLogEvent
已弃用

FirePlayerProgressionEvent
已弃用

GetPlayerSegmentsAsync
暂停
功能: Basic
AnalyticsService:GetPlayerSegmentsAsync(player:Player):Dictionary
参数
player:Player
代码示例
通过玩家分段配置服务器端体验
local Players = game:GetService("Players")
local AnalyticsService = game:GetService("AnalyticsService")
local function configurePlayerExperience(player)
local segments = AnalyticsService:GetPlayerSegmentsAsync(player)
if not segments.HasData then
return
end
if segments.WhenUserFirstPlayed == Enum.WhenUserFirstPlayed.Days0To30 then
print("为", player.Name, "显示额外的入职内容")
end
if segments.ActivePayerStatus == Enum.ActivePayerStatus.Top15Percent then
print("向", player.Name, "显示高价值优惠")
end
end
Players.PlayerAdded:Connect(configurePlayerExperience)

LogCustomEvent
功能: Basic
AnalyticsService:LogCustomEvent(
player:Player, eventName:string, value:number, customFields:Dictionary
):()
参数
player:Player
eventName:string
value:number
默认值:1
customFields:Dictionary
默认值:"nil"
返回
()
代码示例
日志自定义事件
local AnalyticsService = game:GetService("AnalyticsService")
-- 记录任务开始时
AnalyticsService:LogCustomEvent(
player,
"MissionStarted" -- 自定义事件名称
)
-- 记录任务完成时以及耗时
AnalyticsService:LogCustomEvent(
player,
"MissionCompletedDuration", -- 自定义事件名称
120 -- 聚合中使用的事件值
)

LogEconomyEvent
功能: Basic
AnalyticsService:LogEconomyEvent(
player:Player, flowType:Enum.AnalyticsEconomyFlowType, currencyType:string, amount:number, endingBalance:number, transactionType:string, itemSku:string, customFields:Dictionary
):()
参数
player:Player
currencyType:string
amount:number
endingBalance:number
transactionType:string
itemSku:string
customFields:Dictionary
默认值:"nil"
返回
()
代码示例
跟踪应用内购买
local AnalyticsService = game:GetService("AnalyticsService")
AnalyticsService:LogEconomyEvent(
player,
Enum.AnalyticsEconomyFlowType.Source,
"Coins",
1000, -- 捆绑包中有多少金币
1020, -- 交易后的余额
Enum.AnalyticsEconomyTransactionType.IAP.Name,
"1000CoinBundle" -- 金币捆绑包的唯一标识符
)

LogFunnelStepEvent
功能: Basic
AnalyticsService:LogFunnelStepEvent(
player:Player, funnelName:string, funnelSessionId:string, step:number, stepName:string, customFields:Dictionary
):()
参数
player:Player
funnelName:string
funnelSessionId:string
step:number
默认值:1
stepName:string
customFields:Dictionary
默认值:"nil"
返回
()
代码示例
跟踪商店步骤
local AnalyticsService = game:GetService("AnalyticsService")
local HttpService = game:GetService("HttpService")
funnelSessionId = HttpService:GenerateGUID()
-- 记录用户打开商店的时间
AnalyticsService:LogFunnelStepEvent(
player,
"ArmoryCheckout", -- 用于将步骤分组的漏斗名称
funnelSessionId, -- 此唯一结帐会话的漏斗会话 ID
1, -- 步骤编号
"打开商店" -- 步骤名称
)
-- 记录用户查看物品的时间
AnalyticsService:LogFunnelStepEvent(
player,
"ArmoryCheckout", -- 用于将步骤分组的漏斗名称
funnelSessionId, -- 此唯一结帐会话的漏斗会话 ID
2, -- 步骤编号
"查看物品" -- 步骤名称
)
-- 记录用户将物品添加到购物车的时间
AnalyticsService:LogFunnelStepEvent(
player,
"ArmoryCheckout", -- 用于将步骤分组的漏斗名称
funnelSessionId, -- 此唯一结帐会话的漏斗会话 ID
3, -- 步骤编号
"添加到购物车" -- 步骤名称
)

LogOnboardingFunnelStepEvent
功能: Basic
AnalyticsService:LogOnboardingFunnelStepEvent(
player:Player, step:number, stepName:string, customFields:Dictionary
):()
参数
player:Player
step:number
stepName:string
customFields:Dictionary
默认值:"nil"
返回
()
代码示例
跟踪入门步骤
local AnalyticsService = game:GetService("AnalyticsService")
-- 记录FTUE的第一步
AnalyticsService:LogOnboardingFunnelStepEvent(
player,
1, -- 步骤编号
"加入游戏" -- 步骤名称
)
-- 记录FTUE的第二步
AnalyticsService:LogOnboardingFunnelStepEvent(
player,
2, -- 步骤编号
"选择职业" -- 步骤名称
)

LogProgressionCompleteEvent
功能: Basic
AnalyticsService:LogProgressionCompleteEvent(
player:Player, progressionPathName:string, level:number, levelName:string, customFields:Dictionary
):()
参数
player:Player
progressionPathName:string
level:number
levelName:string
customFields:Dictionary
默认值:"nil"
返回
()

LogProgressionEvent
功能: Basic
AnalyticsService:LogProgressionEvent(
player:Player, progressionPathName:string, status:Enum.AnalyticsProgressionType, level:number, levelName:string, customFields:Dictionary
):()
参数
player:Player
progressionPathName:string
level:number
levelName:string
customFields:Dictionary
默认值:"nil"
返回
()

LogProgressionFailEvent
功能: Basic
AnalyticsService:LogProgressionFailEvent(
player:Player, progressionPathName:string, level:number, levelName:string, customFields:Dictionary
):()
参数
player:Player
progressionPathName:string
level:number
levelName:string
customFields:Dictionary
默认值:"nil"
返回
()

LogProgressionStartEvent
功能: Basic
AnalyticsService:LogProgressionStartEvent(
player:Player, progressionPathName:string, level:number, levelName:string, customFields:Dictionary
):()
参数
player:Player
progressionPathName:string
level:number
levelName:string
customFields:Dictionary
默认值:"nil"
返回
()

©2026 Roblox Corporation、Roblox、Roblox 标志及 Powering Imagination 是我们在美国及其他国家或地区的注册与未注册商标。