AnalyticsService

非推奨を表示
作成できません
サービス
複製されていません

AnalyticsService is a collection of methods that allows developers to track how users interact with their experiences, specifically player progression, in-experience economy, funnels, and custom events.

概要

方法

プロパティ

方法

LogCustomEvent

void

Logs an event used to track custom metrics of a user in experience. For additional information, see Custom Events.

パラメータ

player: Player

The user who triggered the event.

eventName: string

The name of the custom event.

value: number

The value of the event that will be used in aggregation.

既定値: 1
customFields: Dictionary

Optional dictionary of custom fields that will provide breakdowns in Roblox-provided charts. Only specific keys, provided by Enum.AnalyticsCustomFieldKeys, will be used for these breakdowns. Limited to 8,000 unique combinations of values across the three custom fields per experience.

既定値: "nil"

戻り値

void

コードサンプル

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

void

Logs an event used to track player actions related in experience.

パラメータ

player: Player

The user who triggered the event.

Should specify the direction that currency is flowing using Enum.AnalyticsEconomyFlowType.

currencyType: string

The name of the currency being added or removed, for example "gold", "gems", or "energy". Limited to 5 unique currency types per experience.

amount: number

The amount of currency being added or removed. This value should always be positive.

endingBalance: number

The user's balance after the currency has been added or removed. This value should always be greater than or equal to 0.

transactionType: string

The type of transaction that occurred. While you're free to use any transaction type, it's recommended to use the provided types from Enum.AnalyticsEconomyTransactionType such as "IAP" or "ContextualPurchase" to enable future insights from Roblox tools and charts.

Because this field type is a string, you'll need to pass the Name value of the enum. For example Enum.AnalyticsEconomyTransactionType.IAP.Name.

Limited to 20 unique types per experience.

itemSku: string

Optional SKU of the item or bundle being purchased. This is a unique identifier for the item being purchased. Limited to 100 unique SKUs per experience.

既定値: ""
customFields: Dictionary

Optional dictionary of custom fields that will provide breakdowns in Roblox-provided charts. Only specific keys, provided by Enum.AnalyticsCustomFieldKeys, will be used for these breakdowns. Limited to 8,000 unique combinations of values across the three custom fields per experience.

既定値: "nil"

戻り値

void

コードサンプル

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

void

Logs an event used to track user actions stepping through a pre-planned funnel. Funnel breakdowns will only consider the user and event values from the first step in a funnel session.

パラメータ

player: Player

The user who triggered the event.

funnelName: string

The name of the funnel. This should be the same for all steps in the funnel. Limited to 10 unique funnels per experience.

funnelSessionId: string

Optional unique identifier for the funnel session. This should be the same for all steps in the funnel.

Note that this field is only necessary for recurring funnels, for example a purchase flow funnel or an item upgrade funnel. If you don't have a natural funnel session identifier, it's recommended to use HttpService:GenerateGUID().

既定値: ""
step: number

The step number in the funnel. This should be unique for each step in the funnel. All funnels start at step 1. Limited to steps 1-100.

Repeated steps by the same user in the same funnel session, or when funnelSessionId is nil will be ignored.

Note that if any steps are skipped, the intermediate steps will be considered completed.

既定値: 1
stepName: string

Optional name of the step in the funnel. This field is only used for display purposes in Roblox-provided charts.

既定値: ""
customFields: Dictionary

Optional dictionary of custom fields that will provide breakdowns in Roblox-provided charts. Only specific keys, provided by Enum.AnalyticsCustomFieldKeys, will be used for these breakdowns. Limited to 8,000 unique combinations of values across the three custom fields per experience.

既定値: "nil"

戻り値

void

コードサンプル

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

void

Logs an event used to track user actions stepping through an onboarding funnel. Funnel breakdowns will only consider the user and event values from the first step in a funnel session.

パラメータ

player: Player

The user who triggered the event.

step: number

The step number in the funnel. This should be unique for each step in the funnel. All funnels start at step 1. Limited to steps 1-100.

Note that if any steps are skipped, the intermediate steps will be considered completed.

stepName: string

Optional name of the step in the funnel. This field is only used for display purposes in Roblox-provided charts.

既定値: ""
customFields: Dictionary

Optional dictionary of custom fields that will provide breakdowns in Roblox-provided charts. Only specific keys, provided by Enum.AnalyticsCustomFieldKeys, will be used for these breakdowns. Limited to 8,000 unique combinations of values across the three custom fields per experience.

既定値: "nil"

戻り値

void

コードサンプル

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

void

Logs an event for when a user has completed a level attempt. This event does not currently display in any Roblox-provided charts.

パラメータ

player: Player

The player who triggered the event.

progressionPathName: string
level: number
levelName: string
既定値: ""
customFields: Dictionary
既定値: "nil"

戻り値

void

LogProgressionEvent

void

Logs an event for when a user has started, completed, or failed a level attempt. This event does not currently display in any Roblox-provided charts.

パラメータ

player: Player

The player who triggered the event.

progressionPathName: string
level: number
levelName: string
既定値: ""
customFields: Dictionary
既定値: "nil"

戻り値

void

LogProgressionFailEvent

void

Logs an event for when a user has failed a level attempt. This event does not currently display in any Roblox-provided charts.

パラメータ

player: Player

The user who triggered the event.

progressionPathName: string
level: number
levelName: string
既定値: ""
customFields: Dictionary
既定値: "nil"

戻り値

void

LogProgressionStartEvent

void

Logs an event for when a user has started a level attempt. This event does not currently display in any Roblox-provided charts.

パラメータ

player: Player

The player who triggered the event.

progressionPathName: string
level: number
levelName: string
既定値: ""
customFields: Dictionary
既定値: "nil"

戻り値

void

イベント