學習
引擎類別
AnalyticsService
無法建立
服務
未複製

*此內容是使用 AI(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,
"硬幣",
1000, -- 套裝中有多少硬幣
1020, -- 交易後的餘額
Enum.AnalyticsEconomyTransactionType.IAP.Name,
"1000硬幣套裝" -- 硬幣套裝的唯一標識符
)

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 是我們在美國及其他國家地區的部分註冊與未註冊商標。