AnalyticsService

Show Deprecated
Not Creatable
Service
Not Replicated

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.

Summary

Methods

Properties

Methods

LogEconomyEvent

void

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

Parameters

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.

Default Value: ""
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 20 unique value per custom field per experience.

Default Value: "nil"

Returns

void

Code Samples

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.

Parameters

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().

Default Value: ""
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.

Default Value: 1
stepName: string

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

Default Value: ""
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 20 unique value per custom field per experience.

Default Value: "nil"

Returns

void

Code Samples

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.

Parameters

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.

Default Value: ""
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 20 unique value per custom field per experience.

Default Value: "nil"

Returns

void

Code Samples

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.

Parameters

player: Player

The player who triggered the event.

progressionPathName: string
level: number
levelName: string
Default Value: ""
customFields: Dictionary
Default Value: "nil"

Returns

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.

Parameters

player: Player

The player who triggered the event.

progressionPathName: string
level: number
levelName: string
Default Value: ""
customFields: Dictionary
Default Value: "nil"

Returns

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.

Parameters

player: Player

The user who triggered the event.

progressionPathName: string
level: number
levelName: string
Default Value: ""
customFields: Dictionary
Default Value: "nil"

Returns

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.

Parameters

player: Player

The player who triggered the event.

progressionPathName: string
level: number
levelName: string
Default Value: ""
customFields: Dictionary
Default Value: "nil"

Returns

void

Events