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.
Summary
Methods
Logs an event used to track custom metrics of a user in experience.
- LogEconomyEvent(player : Player,flowType : Enum.AnalyticsEconomyFlowType,currencyType : string,amount : number,endingBalance : number,transactionType : string,itemSku : string,customFields : Dictionary):void
Logs an event used to track player actions related in experience.
- LogFunnelStepEvent(player : Player,funnelName : string,funnelSessionId : string,step : number,stepName : string,customFields : Dictionary):void
Logs an event used to track user actions stepping through a pre-planned funnel.
- LogOnboardingFunnelStepEvent(player : Player,step : number,stepName : string,customFields : Dictionary):void
Logs an event used to track user actions stepping through an onboarding funnel.
- LogProgressionCompleteEvent(player : Player,progressionPathName : string,level : number,levelName : string,customFields : Dictionary):void
Logs an event for when a user has completed a level attempt.
- LogProgressionEvent(player : Player,progressionPathName : string,status : Enum.AnalyticsProgressionType,level : number,levelName : string,customFields : Dictionary):void
Logs an event for when a user has started, completed, or failed a level attempt.
- LogProgressionFailEvent(player : Player,progressionPathName : string,level : number,levelName : string,customFields : Dictionary):void
Logs an event for when a user has failed a level attempt.
- LogProgressionStartEvent(player : Player,progressionPathName : string,level : number,levelName : string,customFields : Dictionary):void
Logs an event for when a user has started a level attempt.
Properties
Methods
LogCustomEvent
Logs an event used to track custom metrics of a user in experience. For additional information, see Custom Events.
Parameters
The user who triggered the event.
The name of the custom event.
The value of the event that will be used in aggregation.
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.
Returns
Code Samples
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
Logs an event used to track player actions related in experience.
Parameters
The user who triggered the event.
Should specify the direction that currency is flowing using Enum.AnalyticsEconomyFlowType.
The name of the currency being added or removed, for example "gold", "gems", or "energy". Limited to 5 unique currency types per experience.
The amount of currency being added or removed. This value should always be positive.
The user's balance after the currency has been added or removed. This value should always be greater than or equal to 0.
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.
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.
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.
Returns
Code Samples
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
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
The user who triggered the event.
The name of the funnel. This should be the same for all steps in the funnel. Limited to 10 unique funnels per experience.
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().
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.
Optional name of the step in the funnel. This field is only used for display purposes in Roblox-provided charts.
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.
Returns
Code Samples
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
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
The user who triggered the event.
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.
Optional name of the step in the funnel. This field is only used for display purposes in Roblox-provided charts.
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.
Returns
Code Samples
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
Logs an event for when a user has completed a level attempt. This event does not currently display in any Roblox-provided charts.
Parameters
The player who triggered the event.
Returns
LogProgressionEvent
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
The player who triggered the event.
Returns
LogProgressionFailEvent
Logs an event for when a user has failed a level attempt. This event does not currently display in any Roblox-provided charts.
Parameters
The user who triggered the event.
Returns
LogProgressionStartEvent
Logs an event for when a user has started a level attempt. This event does not currently display in any Roblox-provided charts.
Parameters
The player who triggered the event.