> For the complete documentation index, see [llms.txt](https://docs.overdare.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.overdare.com/development/api-reference/classes/analyticsservice.md).

# AnalyticsService

AnalyticsService : `Instance`

## Overview

AnalyticsService is a service that logs what players do in a world as events so that the aggregated results can be checked in Creator Hub.

It logs the occurrence and value of a specific action with a Custom Event, and the tutorial progress of players with an Onboarding Funnel Event. Events are sent only from worlds published as public or private; in a Play Test in Studio, only the arguments passed are checked.

Get AnalyticsService with GetService(). This service works only in a server environment and cannot be called from a client script.

## Properties

## Methods

### LogCustomEvent

Logs one Custom Event. It returns immediately without waiting for the result of the transmission.

An event logged without value and an event logged with a value of 0 are saved as different values. Up to 50 characters of eventName and each Custom Field value are saved, and anything beyond 50 characters is cut off before saving.

#### Parameters

| `Player` player           | The player who triggered the event.                                                                                                                        |
| ------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `string` eventName        | The name of the event. Up to 50 characters are saved, and passing an empty string causes an error.                                                         |
| `number` value            | (Optional) A number logged with the event. Negative numbers and decimals can be used, but NaN and infinity cannot.                                         |
| `Dictionary` customFields | (Optional) A breakdown table that uses the Name of an AnalyticsCustomFieldKeys item as the key and a string as the value. Up to 3 fields can be specified. |

#### Return

| `void` |   |
| ------ | - |

#### Code Samples

```lua
local AnalyticsService = game:GetService("AnalyticsService")

local EventName = "MissionCompleted"

local function OnMissionCompleted(player, clearTime)
    local customFields = {
        [Enum.AnalyticsCustomFieldKeys.CustomField01.Name] = "Tutorial",
    }
    AnalyticsService:LogCustomEvent(player, EventName, clearTime, customFields)
end
```

### LogOnboardingFunnelStepEvent

Logs that a player reached a step of the onboarding funnel. It returns immediately without waiting for the result of the transmission.

Even if the same player logs the same step multiple times, only the first time the step is reached is reflected in the step conversion. If a higher step is logged without logging the steps in between, the earlier steps are also counted as completed.

#### Parameters

| `Player` player           | The player who progressed through the step.                                                                                                                |
| ------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `number` step             | The step number. Use a number from 1 to 100, with up to two decimal places. A value outside this range causes an error.                                    |
| `string` stepName         | (Optional) The step name shown in Creator Hub. Up to 50 characters are saved.                                                                              |
| `Dictionary` customFields | (Optional) A breakdown table that uses the Name of an AnalyticsCustomFieldKeys item as the key and a string as the value. Up to 3 fields can be specified. |

#### Return

| `void` |   |
| ------ | - |

#### Code Samples

```lua
local Players = game:GetService("Players")
local AnalyticsService = game:GetService("AnalyticsService")

local JoinStep = 1
local JoinStepName = "Join"

local function OnPlayerAdded(player)
    AnalyticsService:LogOnboardingFunnelStepEvent(player, JoinStep, JoinStepName)
end
Players.PlayerAdded:Connect(OnPlayerAdded)
```

## Events

## See also

{% content-ref url="/pages/H5tMKHjo2KZOb6EiodUS" %}
[Analytics](https://docs.overdare.com/manual/script-manual/advanced-gameplay-systems/analytics.md)
{% endcontent-ref %}
