分析服務務 是一個可讓開發人員跟蹤用戶與他們的體驗互動方式的方法,例如玩家進度、體驗經濟、階段和自訂事件。
概要
方法
記錄使用者在體驗中的自訂指標。
- LogEconomyEvent(player : Player,flowType : Enum.AnalyticsEconomyFlowType,currencyType : string,amount : number,endingBalance : number,transactionType : string,itemSku : string,customFields : Dictionary):void
記錄使用者在體驗中相關的行動。
- LogFunnelStepEvent(player : Player,funnelName : string,funnelSessionId : string,step : number,stepName : string,customFields : Dictionary):void
記錄使用預設計劃的階段讓用戶執行的行動。
- LogOnboardingFunnelStepEvent(player : Player,step : number,stepName : string,customFields : Dictionary):void
記錄使用者通過 onboarding funnel 的步驟。
- LogProgressionCompleteEvent(player : Player,progressionPathName : string,level : number,levelName : string,customFields : Dictionary):void
記錄一個用戶完成等級嘗試時發生的事件。
- LogProgressionEvent(player : Player,progressionPathName : string,status : Enum.AnalyticsProgressionType,level : number,levelName : string,customFields : Dictionary):void
記錄一個用戶開始、完成或失敗一個層級嘗試的時間。
- LogProgressionFailEvent(player : Player,progressionPathName : string,level : number,levelName : string,customFields : Dictionary):void
記錄使用者對等級嘗試失敗時發生的事件。
- LogProgressionStartEvent(player : Player,progressionPathName : string,level : number,levelName : string,customFields : Dictionary):void
記錄一個玩家開始等級攻嘗試時發生的事件。
屬性
方法
LogCustomEvent
記錄使用者在體驗中的自訂指標。如需更多資訊,請參閱 自訂事件。
參數
發生事件的用戶。
自訂事件的名稱。
用於聚合的事件值。
可選擇的自訂字典,可在 Roblox 提供的圖形中提供分解。只有 Enum.AnalyticsCustomFieldKeys 提供的特定鑰匙才會用於這些分解。對於這些分解,只有 8,000 個獨特值的值在三個自訂字段中。
返回
範例程式碼
This example uses AnalyticsService:LogCustomEvent() to log two custom events: MissionStarted and MissionCompletedDuration.
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
記錄使用者在體驗中相關的行動。
參數
發生事件的用戶。
應該指定貨幣正在流動的方向使用 Enum.AnalyticsEconomyFlowType。
貨幣的名稱,例如 "gold" , "gems" 或 "energy" 。每個體驗限定 5 種貨幣類型。
添加或移除貨幣的數量。此值應該總是是正的。
貨幣已添加或移除後的使用者餘額。這值應該總是大於或等於 0。
發生的交易類型。雖然您自由使用任何交易類輸入,但建議您使用 Enum.AnalyticsEconomyTransactionType 提供的類型,例如 "IAP" 或 "ContextualPurchase" 來啟用未來 Roblox 工具和圖形的未來洞察能力。
因為此字段類型是字串,因此您需要通過枚列的 Name 值。例如 Enum.AnalyticsEconomyTransactionType.IAP.Name 。
每個體驗限定 20 種類型。
購買物品或組合包的可選購買標識。這是物品購買時的獨一無二的標識。每個體驗限定 100 個獨特標識。
可選擇的自訂字典,可在 Roblox 提供的圖形中提供分解。只有 Enum.AnalyticsCustomFieldKeys 提供的特定鑰匙才會用於這些分解。對於這些分解,只有 8,000 個獨特值的值在三個自訂字段中。
返回
範例程式碼
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.
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
記錄使用預設訓發程式追蹤用戶行動的事件。事件分解只會考慮從訓發程式第一個步驟開始的用戶和事件值。
參數
發生事件的用戶。
煙囪的名稱。這應該是所有步驟在煙囪中的相同。每個體驗限定 10 個獨特煙囪。
可選的獨特標識 for 隧道會作業。這應該是所有隧道會話的相同。
注意,此字段僅適用於 重複 的 funnel,例如購買流程 funnel 或物品升級 funnel。如果您沒有自然的 funnel session identifier,建議使用 HttpService:GenerateGUID()。
階段編號在煙囪中。這應該是每個階段在煙囪中獨一無二的。所有階段都從第 1 步開始。限定於步驟 1-100。
重複同一用戶在同一個 funnel 會作業中的步驟,或 funnelSessionId 是 nil 時會被忽略。
注意,如果任何步驟被跳過,將視為已完成。
可選擇的步驟名稱。此字段只用於顯示目的。
可選擇的自訂字典,可在 Roblox 提供的圖形中提供分解。只有 Enum.AnalyticsCustomFieldKeys 提供的特定鑰匙才會用於這些分解。對於這些分解,只有 8,000 個獨特值的值在三個自訂字段中。
返回
範例程式碼
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.
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
記錄使用者通過階段式導入管道踏入的事件。導入管道會僅考慮從第一個階作業開始的使用者和事件值。
參數
發生事件的用戶。
階段編號在煙囪中。這應該是每個階段在煙囪中獨一無二的。所有階段都從第 1 步開始。限定於步驟 1-100。
注意,如果任何步驟被跳過,將視為已完成。
可選擇的步驟名稱。此字段只用於顯示目的。
可選擇的自訂字典,可在 Roblox 提供的圖形中提供分解。只有 Enum.AnalyticsCustomFieldKeys 提供的特定鑰匙才會用於這些分解。對於這些分解,只有 8,000 個獨特值的值在三個自訂字段中。
返回
範例程式碼
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.
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 提供的圖形中不顯示。
參數
發生事件的玩家。
返回
LogProgressionEvent
記錄一個用戶開始、完成或失敗嘗試任何等級時的事件。這個事件目前在任何 Roblox 提供的圖形中不會顯示。
參數
發生事件的玩家。
返回
LogProgressionFailEvent
記錄一個用戶在嘗試升級時失敗的事件。這個事件目前在 Roblox 提供的圖形中不會顯示。
參數
發生事件的用戶。
返回
LogProgressionStartEvent
記錄一個用戶開始等級攻嘗試時發生的事件。這個事件目前在任何 Roblox 提供的圖形中不會顯示。
參數
發生事件的玩家。