# AnalyticsService

Roblox Engine API class from Roblox Studio 0.744.0.7441077 (version-7aaa6838d36c4448).

- Inherits from, nearest first: [Instance](https://rapi.sleaze.dev/classes/Instance.md), [Object](https://rapi.sleaze.dev/classes/Object.md)
- Tags: Not creatable, Not replicated, Service
- Memory category: Instances
- HTML page: https://rapi.sleaze.dev/classes/AnalyticsService/
- Roblox documentation: https://create.roblox.com/docs/reference/engine/classes/AnalyticsService

Collection of methods that allows you to track how users interact with your experiences.

## Properties

### ApiKey

```luau
AnalyticsService.ApiKey: string = ""
```

- Tags: Deprecated, Local user security, Read capabilities: Basic

**Deprecated:** This property is deprecated. Do not use it for new work.

PlayFab API key. Must be set in order to use [`FireEvent`](https://rapi.sleaze.dev/classes/AnalyticsService.md).

## Methods

### GetDurationLoggerTimestamp

```luau
AnalyticsService:GetDurationLoggerTimestamp(): number
```

- Tags: Capabilities: Basic + InternalTest

### GetPlayerSegmentsAsync

```luau
AnalyticsService:GetPlayerSegmentsAsync(player: Player): { [string]: any }
```

- Tags: Yields, Capabilities: Basic

Returns coarse player segment buckets for the current experience.

Parameters:

- `player`: The player whose segment buckets should be returned.

Returns: A dictionary containing coarse player segment buckets for the current experience.

### LogCustomEvent

```luau
AnalyticsService:LogCustomEvent(player: Player, eventName: string, value: number? = 1, customFields: { [string]: any }? = nil)
```

- Tags: Capabilities: Basic

Logs an event used to track custom metrics of a user in experience.

Parameters:

- `player`: The user who triggered the event.
- `eventName`: The name of the custom event.
- `value`: The value of the event that will be used in aggregation.
- `customFields`: Optional dictionary of custom fields that will provide breakdowns in Roblox-provided charts. Only specific keys, provided by `AnalyticsCustomFieldKeys`, will be used for these breakdowns. Limited to 8,000 unique combinations of values across the three custom fields per experience.

### LogEconomyEvent

```luau
AnalyticsService:LogEconomyEvent(player: Player, flowType: Enum.AnalyticsEconomyFlowType, currencyType: string, amount: number, endingBalance: number, transactionType: string, itemSku: string? = "", customFields: { [string]: any }? = nil)
```

- Tags: Capabilities: Basic

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

Parameters:

- `player`: The user who triggered the event.
- `flowType`: Should specify the direction that currency is flowing using `AnalyticsEconomyFlowType`.
- `currencyType`: The name of the currency being added or removed, for example `"gold"`, `"gems"`, or `"energy"`. Limited to 5 unique currency types per experience.
- `amount`: The amount of currency being added or removed. This value should always be positive.
- `endingBalance`: The user's balance after the currency has been added or removed. This value should always be greater than or equal to `0`.
- `transactionType`: The type of transaction that occurred. While you're free to use any transaction type, it's recommended to use the provided types from `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`](https://rapi.sleaze.dev/classes/Instance.md) value of the enum. For example `Enum.AnalyticsEconomyTransactionType.IAP.Name`. Limited to 20 unique types per experience.
- `itemSku`: 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`: Optional dictionary of custom fields that will provide breakdowns in Roblox-provided charts. Only specific keys, provided by `AnalyticsCustomFieldKeys`, will be used for these breakdowns. Limited to 8,000 unique combinations of values across the three custom fields per experience.

### LogFunnelStepEvent

```luau
AnalyticsService:LogFunnelStepEvent(player: Player, funnelName: string, funnelSessionId: string? = "", step: number? = 1, stepName: string? = "", customFields: { [string]: any }? = nil)
```

- Tags: Capabilities: Basic

Logs an event used to track user actions stepping through a pre-planned funnel.

Parameters:

- `player`: The user who triggered the event.
- `funnelName`: The name of the funnel. This should be the same for all steps in the funnel. Limited to 10 unique funnels per experience.
- `funnelSessionId`: 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()`](https://rapi.sleaze.dev/classes/HttpService.md).
- `step`: 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.
- `stepName`: Optional name of the step in the funnel. This field is only used for display purposes in Roblox-provided charts.
- `customFields`: Optional dictionary of custom fields that will provide breakdowns in Roblox-provided charts. Only specific keys, provided by `AnalyticsCustomFieldKeys`, will be used for these breakdowns. Limited to 8,000 unique combinations of values across the three custom fields per experience.

### LogJourneyEvent

```luau
AnalyticsService:LogJourneyEvent(player: Player, journeyName: string, nodeName: string, journeySessionId: string? = "", customFields: { [string]: any }? = nil)
```

- Tags: Capabilities: Basic

Logs a journey event used to track non-linear player paths through an experience.

Parameters:

- `player`: The player who triggered the journey event.
- `journeyName`: The name of the journey. This should be the same for all nodes in the journey. Cannot be empty and cannot contain a comma `,`, double quote `"`, single quote `'`, or newline character.
- `nodeName`: The name of the node the player reached in the journey. Cannot be empty, cannot contain a comma `,`, double quote `"`, single quote `'`, or newline character, and cannot start with `__` (double underscore), which is reserved.
- `journeySessionId`: Optional unique identifier for the journey session. This should be the same for all nodes in a single session of the journey. If provided, cannot contain a comma `,`, double quote `"`, single quote `'`, or newline character.
- `customFields`: Optional dictionary of custom fields that will provide breakdowns in Roblox-provided charts. Only specific keys, provided by `AnalyticsCustomFieldKeys`, will be used for these breakdowns. Limited to 8,000 unique combinations of values across the three custom fields per experience.

### LogOnboardingFunnelStepEvent

```luau
AnalyticsService:LogOnboardingFunnelStepEvent(player: Player, step: number, stepName: string? = "", customFields: { [string]: any }? = nil)
```

- Tags: Capabilities: Basic

Logs an event used to track user actions stepping through an onboarding funnel.

Parameters:

- `player`: The user who triggered the event.
- `step`: 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`: Optional name of the step in the funnel. This field is only used for display purposes in Roblox-provided charts.
- `customFields`: Optional dictionary of custom fields that will provide breakdowns in Roblox-provided charts. Only specific keys, provided by `AnalyticsCustomFieldKeys`, will be used for these breakdowns. Limited to 8,000 unique combinations of values across the three custom fields per experience.

### LogProgressionCompleteEvent

```luau
AnalyticsService:LogProgressionCompleteEvent(player: Player, progressionPathName: string, level: number, levelName: string? = "", customFields: { [string]: any }? = nil)
```

- Tags: Capabilities: Basic

Logs an event for when a user has completed a level attempt.

Parameters:

- `player`: The player who triggered the event.
- `progressionPathName`: The name of the progression path this event belongs to, such as a world, chapter, or level group. This groups related progression events together. Cannot be empty and cannot contain a comma `,`, double quote `"`, single quote `'`, or newline character.
- `level`: The numeric level the player is progressing through within the progression path.
- `levelName`: The name of the level associated with this event. This field is used for display purposes in Roblox-provided charts.
- `customFields`: Optional dictionary of custom fields that will provide breakdowns in Roblox-provided charts. Only specific keys, provided by `AnalyticsCustomFieldKeys`, will be used for these breakdowns. Limited to 8,000 unique combinations of values across the three custom fields per experience.

### LogProgressionEvent

```luau
AnalyticsService:LogProgressionEvent(player: Player, progressionPathName: string, status: Enum.AnalyticsProgressionType, level: number, levelName: string? = "", customFields: { [string]: any }? = nil)
```

- Tags: Capabilities: Basic

Logs an event for when a user has started, completed, or failed a level attempt.

Parameters:

- `player`: The player who triggered the event.
- `progressionPathName`: The name of the progression path this event belongs to, such as a world, chapter, or level group. This groups related progression events together. Cannot be empty and cannot contain a comma `,`, double quote `"`, single quote `'`, or newline character.
- `status`: The progression status to record, provided as an `AnalyticsProgressionType` value such as `Start`, `Complete`, or `Fail`. The [`AnalyticsService:LogProgressionStartEvent()`](https://rapi.sleaze.dev/classes/AnalyticsService.md), [`AnalyticsService:LogProgressionCompleteEvent()`](https://rapi.sleaze.dev/classes/AnalyticsService.md), and [`AnalyticsService:LogProgressionFailEvent()`](https://rapi.sleaze.dev/classes/AnalyticsService.md) methods are shortcuts that set this status for you.
- `level`: The numeric level the player is progressing through within the progression path.
- `levelName`: The name of the level associated with this event. This field is used for display purposes in Roblox-provided charts.
- `customFields`: Optional dictionary of custom fields that will provide breakdowns in Roblox-provided charts. Only specific keys, provided by `AnalyticsCustomFieldKeys`, will be used for these breakdowns. Limited to 8,000 unique combinations of values across the three custom fields per experience.

### LogProgressionFailEvent

```luau
AnalyticsService:LogProgressionFailEvent(player: Player, progressionPathName: string, level: number, levelName: string? = "", customFields: { [string]: any }? = nil)
```

- Tags: Capabilities: Basic

Logs an event for when a user has failed a level attempt.

Parameters:

- `player`: The user who triggered the event.
- `progressionPathName`: The name of the progression path this event belongs to, such as a world, chapter, or level group. This groups related progression events together. Cannot be empty and cannot contain a comma `,`, double quote `"`, single quote `'`, or newline character.
- `level`: The numeric level the player is progressing through within the progression path.
- `levelName`: The name of the level associated with this event. This field is used for display purposes in Roblox-provided charts.
- `customFields`: Optional dictionary of custom fields that will provide breakdowns in Roblox-provided charts. Only specific keys, provided by `AnalyticsCustomFieldKeys`, will be used for these breakdowns. Limited to 8,000 unique combinations of values across the three custom fields per experience.

### LogProgressionStartEvent

```luau
AnalyticsService:LogProgressionStartEvent(player: Player, progressionPathName: string, level: number, levelName: string? = "", customFields: { [string]: any }? = nil)
```

- Tags: Capabilities: Basic

Logs an event for when a user has started a level attempt.

Parameters:

- `player`: The player who triggered the event.
- `progressionPathName`: The name of the progression path this event belongs to, such as a world, chapter, or level group. This groups related progression events together. Cannot be empty and cannot contain a comma `,`, double quote `"`, single quote `'`, or newline character.
- `level`: The numeric level the player is progressing through within the progression path.
- `levelName`: The name of the level associated with this event. This field is used for display purposes in Roblox-provided charts.
- `customFields`: Optional dictionary of custom fields that will provide breakdowns in Roblox-provided charts. Only specific keys, provided by `AnalyticsCustomFieldKeys`, will be used for these breakdowns. Limited to 8,000 unique combinations of values across the three custom fields per experience.

### FireCustomEvent

```luau
AnalyticsService:FireCustomEvent(player: Instance, eventCategory: string, customData: any)
```

- Tags: Deprecated, Capabilities: Basic

**Deprecated:** This deprecated function is a variant of [`AnalyticsService:LogCustomEvent()`](https://rapi.sleaze.dev/classes/AnalyticsService.md) which should be used instead.

Fires a custom event with a custom event name and data.

Parameters:

- `player`: The player who triggered the custom event. `nil` if not player related.
- `eventCategory`: User defined category. This should be the name of the event.
- `customData`: Optional. User defined data, could be a string, a number or a table.

### FireEvent

```luau
AnalyticsService:FireEvent(category: string, value: any)
```

- Tags: Deprecated, Capabilities: Basic

**Deprecated:** This function has been deprecated in favor of more descriptive methods, including [`AnalyticsService:LogCustomEvent()`](https://rapi.sleaze.dev/classes/AnalyticsService.md), [`AnalyticsService:LogEconomyEvent()`](https://rapi.sleaze.dev/classes/AnalyticsService.md), and [`AnalyticsService:LogProgressionEvent()`](https://rapi.sleaze.dev/classes/AnalyticsService.md).

Report a custom event to PlayFab.

Parameters:

- `category`: 'The category of event to report. Cannot contain the following characters: comma `,`, double quote `"` or newline characters `\r\n`'.
- `value`: A value to be serialized and reported. Serialized length must not exceed 1 KiB, or 1024 bytes.

### FireInGameEconomyEvent

```luau
AnalyticsService:FireInGameEconomyEvent(player: Instance, itemName: string, economyAction: Enum.AnalyticsEconomyAction, itemCategory: string, amount: number, currency: string, location: any, customData: any)
```

- Tags: Deprecated, Capabilities: Basic

**Deprecated:** This deprecated function is a variant of [`AnalyticsService:LogEconomyEvent()`](https://rapi.sleaze.dev/classes/AnalyticsService.md) which should be used instead.

Fire an event used to track player actions pertaining to the in-game

Parameters:

- `player`: The player who triggered the economy event.
- `itemName`: The name of the item.
- `economyAction`: Indicates the acquisition or spending of an in game resource.
- `itemCategory`: A user defined category for items such as "Vehicle," "Weapon.".
- `amount`: The amount of the currency.
- `currency`: The currency used. Examples: 'gold', 'gems', 'life.'.
- `location`: The event location. A dictionary that each key-value represents an entry of location data. The key-value is a string-string pair. With this you can query which are the most popular "stores" then maybe you want to increase/lower the price for the stores. See the example below:

```luau
local location = {     ["placeDesc"] = "Dungeon1",     ["levelDesc"] = "level2",     ["mapDesc"] = "LeftChamberMap",     ["storeName"] = "DarkSmith",     ["userDefinedKey"] = "0005" }
```
- `customData`: Optional. User defined data, could be a string, a number or a table.

### FireLogEvent

```luau
AnalyticsService:FireLogEvent(player: Instance, logLevel: Enum.AnalyticsLogLevel, message: string, debugInfo: any, customData: any)
```

- Tags: Deprecated, Capabilities: Basic

**Deprecated:** This method is deprecated. Do not use it for new work.

Fire a log event used to track errors and warnings experienced by players.

Parameters:

- `player`: The player who triggered the error event, `nil` if not player related.
- `logLevel`: The specified log level (e.g. Debug, Error).
- `message`: User defined message.
- `debugInfo`: Optional. A dictionary which contains predefined keys including "errorCode" and "stackTrace". Both keys values are strings. stackTrace is a traceback of the current function call stack.
- `customData`: Optional. User defined data, could be a string, a number or a table.

### FirePlayerProgressionEvent

```luau
AnalyticsService:FirePlayerProgressionEvent(player: Instance, category: string, progressionStatus: Enum.AnalyticsProgressionStatus, location: any, statistics: any, customData: any)
```

- Tags: Deprecated, Capabilities: Basic

**Deprecated:** This deprecated function is a variant of [`AnalyticsService:LogProgressionEvent()`](https://rapi.sleaze.dev/classes/AnalyticsService.md) which should be used instead.

Fire an event used to track player progression through the game.

Parameters:

- `player`: The player who triggered the event.
- `category`: A user defined category for progression.
- `progressionStatus`: Indicates the status of the progression.
- `location`: The event location. A dictionary that each key-value represents an entry of location data. The key-value is a string-string pair. With this developers can query where is the most frequent location for a specific progression event category. For example, the category could be "LevelUp".
- `statistics`: Optional. A dictionary that each key-value represents an entry of statistics data that allows developers to track any specific data that they want to collect as players progress through their game. Key-Value is a string-number pair.
- `customData`: Optional. User defined data, could be a string, a number or a table.

## Inherited members

- From [Instance](https://rapi.sleaze.dev/classes/Instance.md): `Archivable`, `archivable`, `Attributes`, `AttributesReplicate`, `AttributesSerialize`, `HistoryId`, `Name`, `Parent`, `PredictionMode`, `PropertyStatusStudio`, `RobloxLocked`, `SerializedOverrides`, `SourceAssetId`, `Tags`, `UniqueId`, `numExpectedDirectChildren`, `DataCost`, `Capabilities`, `DefinesCapabilities`, `IsInSandbox`, `Sandboxed`, `AddTag`, `ClearAllChildren`, `Clone`, `Destroy`, `FindFirstAncestor`, `FindFirstAncestorOfClass`, `FindFirstAncestorWhichIsA`, `FindFirstChild`, `FindFirstChildOfClass`, `FindFirstChildWhichIsA`, `FindFirstDescendant`, `GetActor`, `GetAttribute`, `GetAttributeChangedSignal`, `GetAttributes`, `GetChildren`, `GetDebugId`, `GetDescendants`, `GetFullName`, `GetStyled`, `GetStyledPropertyChangedSignal`, `GetTags`, `HasTag`, `IsAncestorOf`, `IsDescendantOf`, `IsPropertyModified`, `QueryDescendants`, `RemoveTag`, `ResetPropertyToDefault`, `SetAttribute`, `WaitForChild`, `Remove`, `children`, `clone`, `destroy`, `findFirstChild`, `getChildren`, `isDescendantOf`, `remove`, `AncestryChanged`, `AttributeChanged`, `ChildAdded`, `ChildRemoved`, `DescendantAdded`, `DescendantRemoving`, `Destroying`, `StyledPropertiesChanged`, `childAdded`
- From [Object](https://rapi.sleaze.dev/classes/Object.md): `ClassName`, `className`, `GetPropertyChangedSignal`, `IsA`, `isA`, `Changed`
