AnalyticsService

顯示已棄用項目

*此內容是使用 AI(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。這個值應該永遠大於或等於 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"

返回

()

活動