Analytics Service
*เนื้อหานี้แปลโดยใช้ AI (เวอร์ชัน Beta) และอาจมีข้อผิดพลาด หากต้องการดูหน้านี้เป็นภาษาอังกฤษ ให้คลิกที่นี่
ข้อมูลสรุป
วิธีการ
FireCustomEvent(player: Instance,eventCategory: string,customData: 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):() |
GetPlayerSegmentsAsync(player: Player):Dictionary |
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):() |
LogJourneyEvent(player: Player,journeyName: string,nodeName: string,journeySessionId: 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
คุณสมบัติ
Api Key
วิธีการ
Fire Custom Event
Fire Event
Fire In Game Economy Event
Fire Log Event
Fire Player Progression Event
Get Player Segments Async
พารามิเตอร์
ส่งค่ากลับ
ตัวอย่างโค้ด
กำหนดประสบการณ์ฝั่งเซิร์ฟเวอร์ด้วยกลุ่มผู้เล่น
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)Log Custom Event
Analytics Service: Log Custom Event(
):()
พารามิเตอร์
| ค่าเริ่มต้น: 1 |
| ค่าเริ่มต้น: nil |
ส่งค่ากลับ
()
ตัวอย่างโค้ด
บันทึกเหตุการณ์ที่กำหนดเอง
local AnalyticsService = game:GetService("AnalyticsService")
local Players = game:GetService("Players")
local missionBoard = script.Parent
local missionStartTimes: { [Player]: number } = {}
local prompt = Instance.new("ProximityPrompt")
prompt.ActionText = "ภารกิจ"
prompt.Parent = missionBoard
prompt.Triggered:Connect(function(player)
local startTime = missionStartTimes[player]
if startTime == nil then
-- ผู้เล่นยอมรับภารกิจ
missionStartTimes[player] = os.clock()
AnalyticsService:LogCustomEvent(
player,
"MissionStarted" -- ชื่อเหตุการณ์ที่กำหนดเอง
)
else
-- ผู้เล่นส่งภารกิจ
missionStartTimes[player] = nil
AnalyticsService:LogCustomEvent(
player,
"MissionCompletedDuration", -- ชื่อเหตุการณ์ที่กำหนดเอง
os.clock() - startTime -- ค่าของเหตุการณ์ที่ใช้ในการรวม: วินาทีที่ภารกิจใช้
)
end
end)
Players.PlayerRemoving:Connect(function(player)
missionStartTimes[player] = nil
end)Log Economy Event
Analytics Service: Log Economy Event(
player:Player, flow Type:Enum.AnalyticsEconomyFlowType, currency Type:string, amount:number, ending Balance:number, transaction Type:string, item Sku:string, custom Fields:Dictionary
):()
พารามิเตอร์
| ค่าเริ่มต้น: nil |
ส่งค่ากลับ
()
ตัวอย่างโค้ด
ติดตามการซื้อในแอป
local AnalyticsService = game:GetService("AnalyticsService")
local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local COIN_BUNDLE_PRODUCT_ID = 123456 -- เปลี่ยนเป็น ID ของผลิตภัณฑ์นักพัฒนาของคุณ
local COINS_IN_BUNDLE = 1000
-- แทนที่สำหรับการจัดเก็บข้อมูลของคุณเอง: ผู้เล่นแต่ละคนมีเหรียญกี่เหรียญ
local coinBalances: { [Player]: number } = {}
MarketplaceService.ProcessReceipt = function(receiptInfo)
local player = Players:GetPlayerByUserId(receiptInfo.PlayerId)
if not player then
return Enum.ProductPurchaseDecision.NotProcessedYet
end
if receiptInfo.ProductId == COIN_BUNDLE_PRODUCT_ID then
local balance = (coinBalances[player] or 0) + COINS_IN_BUNDLE
coinBalances[player] = balance
AnalyticsService:LogEconomyEvent(
player,
Enum.AnalyticsEconomyFlowType.Source,
"เหรียญ",
COINS_IN_BUNDLE, -- จำนวนเหรียญในชุด
balance, -- ยอดคงเหลือหลังการทำธุรกรรม
Enum.AnalyticsEconomyTransactionType.IAP.Name,
"1000CoinBundle" -- ตัวระบุเฉพาะของชุดเหรียญ
)
end
return Enum.ProductPurchaseDecision.PurchaseGranted
endLog Funnel Step Event
ส่งค่ากลับ
()
ตัวอย่างโค้ด
ติดตามขั้นตอนร้านค้า
local AnalyticsService = game:GetService("AnalyticsService")
local HttpService = game:GetService("HttpService")
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local FUNNEL_NAME = "ArmoryCheckout" -- ชื่อฟันเนลที่ใช้ในการจัดกลุ่มขั้นตอน
-- หมายเลขและชื่อขั้นตอนสำหรับแต่ละการกระทำที่ลูกค้าสามารถรายงานได้
local STEPS = {
OpenStore = { number = 1, name = "เปิดร้าน" },
ViewItem = { number = 2, name = "ดูสินค้า" },
AddToCart = { number = 3, name = "เพิ่มลงในตะกร้า" },
}
-- ลูกค้าจะส่งเหตุการณ์นี้ด้วย "OpenStore", "ViewItem" หรือ "AddToCart" ขณะที่ UI ของร้านค้าใช้งานอยู่
local shopActionEvent = Instance.new("RemoteEvent")
shopActionEvent.Name = "ShopAction"
shopActionEvent.Parent = ReplicatedStorage
local funnelSessionIds: { [Player]: string } = {}
shopActionEvent.OnServerEvent:Connect(function(player, action)
local step = STEPS[action]
if step == nil then
return
end
if action == "OpenStore" then
-- ทุกครั้งที่ร้านเปิดจะเริ่มเซสชันการชำระเงินใหม่
funnelSessionIds[player] = HttpService:GenerateGUID()
end
local funnelSessionId = funnelSessionIds[player]
if funnelSessionId == nil then
return
end
AnalyticsService:LogFunnelStepEvent(
player,
FUNNEL_NAME,
funnelSessionId, -- รหัสเซสชันฟันเนลสำหรับเซสชันการชำระเงินที่ไม่ซ้ำกันนี้
step.number, -- หมายเลขขั้นตอน
step.name -- ชื่อขั้นตอน
)
end)
Players.PlayerRemoving:Connect(function(player)
funnelSessionIds[player] = nil
end)Log Journey Event
Analytics Service: Log Journey Event(
player:Player, journey Name:string, node Name:string, journey Session Id:string, custom Fields:Dictionary
):()
พารามิเตอร์
| ค่าเริ่มต้น: nil |
ส่งค่ากลับ
()
Log Onboarding Funnel Step Event
Analytics Service: Log Onboarding Funnel Step Event(
):()
พารามิเตอร์
| ค่าเริ่มต้น: nil |
ส่งค่ากลับ
()
ตัวอย่างโค้ด
ติดตามขั้นตอนการเริ่มต้น
local AnalyticsService = game:GetService("AnalyticsService")
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
-- ไคลเอนต์จะเรียกใช้งานนี้เมื่อผู้เล่นเลือกคลาสใน UI การเริ่มต้น
local chooseClassEvent = Instance.new("RemoteEvent")
chooseClassEvent.Name = "ChooseClass"
chooseClassEvent.Parent = ReplicatedStorage
Players.PlayerAdded:Connect(function(player)
-- บันทึกขั้นตอนแรกของ FTUE
AnalyticsService:LogOnboardingFunnelStepEvent(
player,
1, -- หมายเลขขั้นตอน
"Joined Game" -- ชื่อขั้นตอน
)
end)
chooseClassEvent.OnServerEvent:Connect(function(player)
-- บันทึกขั้นตอนที่สองของ FTUE
AnalyticsService:LogOnboardingFunnelStepEvent(
player,
2, -- หมายเลขขั้นตอน
"Choose Class" -- ชื่อขั้นตอน
)
end)Log Progression Complete Event
Analytics Service: Log Progression Complete Event(
):()
พารามิเตอร์
| ค่าเริ่มต้น: nil |
ส่งค่ากลับ
()
Log Progression Event
Analytics Service: Log Progression Event(
player:Player, progression Path Name:string, status:Enum.AnalyticsProgressionType, level:number, level Name:string, custom Fields:Dictionary
):()
พารามิเตอร์
| ค่าเริ่มต้น: nil |
ส่งค่ากลับ
()
Log Progression Fail Event
Analytics Service: Log Progression Fail Event(
):()
พารามิเตอร์
| ค่าเริ่มต้น: nil |
ส่งค่ากลับ
()
Log Progression Start Event
Analytics Service: Log Progression Start Event(
):()
พารามิเตอร์
| ค่าเริ่มต้น: nil |
ส่งค่ากลับ
()