Analytics SDK

Custom events

Track anything that happens in your game with TrackEvent, plus funnel steps and progression, and learn the naming and property rules.

Custom events are the moments that matter in your game: a pet hatched, a boss spawned, a quest abandoned. Track them with Analytics:TrackEvent and they appear in Events, Explore and the funnel builder.

Analytics:TrackEvent(player, "PetHatched", {
	PetName = "Dragon",
	Rarity = "Legendary",
	Island = 3,
})

#Signature

Analytics:TrackEvent(player: Player?, name: string, properties: { [string]: any }?)
Analytics:TrackEvent(name: string, properties: { [string]: any }?, player: Player?)

Both forms do the same thing. If the first argument is a Player, it is the player and the name comes next; otherwise the name comes first and the player, if any, comes last.

  • With a player, the event is attributed to them and their current session. Use this for anything a player did.
  • Without a player, it is a server-level event, such as a boss spawning or a round ending.
-- Player events
Analytics:TrackEvent(player, "QuestAbandoned", { Quest = "Lost Kitten", Minutes = 4 })
Analytics:TrackEvent("QuestAbandoned", { Quest = "Lost Kitten" }, player)

-- Server events
Analytics:TrackEvent("BossSpawned", { Boss = "Kraken" })
Analytics:TrackEvent("RoundEnded")

TrackEvent returns nothing and never yields: it only adds the event to the queue.

#Naming rules

An event name must:

  • start with a letter (A–Z, a–z);
  • contain only letters, digits, spaces and _ . : -;
  • be at most 64 characters.

Names starting with $ are reserved for the SDK's own events (see the event reference), so a custom event can never be mistaken for one. A name that breaks the rules is dropped with the warning TrackEvent: invalid event name <name>.

Pick one style and keep to it. Names are case-sensitive, so PetHatched and pet_hatched are two different events in every chart. PascalCase verbs in the past tense (ShopOpened, PetHatched, RebirthCompleted) read well in the dashboard.

Put what varies into properties, not the name. PetHatched with { Rarity = "Legendary" } lets you break down by rarity; LegendaryPetHatched, RarePetHatched and so on can't be compared in one chart.

#Properties

Properties are a flat table of up to 32 keys.

Rule Limit
Number of properties 32 per event. Extra properties are dropped with only the first 32 properties are kept. Lua tables have no fixed order, so which ones are kept isn't defined: stay under the limit.
Key Starts with a letter or _; then letters, digits, spaces and _ . -; at most 40 characters. Other keys are dropped with dropped invalid property name <key>.
String value Cut to 256 characters.
Number value Must be finite. NaN, math.huge and -math.huge are dropped silently.
Boolean value Sent as it is.
EnumItem or Instance Converted with tostring, so Enum.Material.Grass becomes "Enum.Material.Grass" and an Instance becomes its Name.
Anything else Tables, Vector3, CFrame, functions and other types are dropped with property <key> has unsupported type <type>.

An empty table is the same as no properties. If properties isn't a table at all, the event is still sent, with no properties, and the SDK warns <name>: properties must be a table.

Analytics:TrackEvent(player, "ItemCrafted", {
	Item = "Iron Sword",
	Tier = 2,
	FirstTime = true,
	Material = Enum.Material.Metal, -- sent as "Enum.Material.Metal"
	Position = character:GetPivot().Position, -- dropped: unsupported type Vector3
})

If you need a vector or a list, flatten it yourself: { X = pos.X, Z = pos.Z }, or a comma-separated string.

#When events are dropped

Situation What happens
Invalid name Dropped in game, with a warning.
player given but not a Player Dropped in game: TrackEvent(<name>): player must be a Player.
Custom events turned off in the dashboard Dropped in game once servers load the change, and rejected by the API in the meantime. No warning.
Name listed in Blocked events Same as above. Use this to silence a noisy event without publishing.
SDK not started, or Studio without TrackInStudio Ignored.

Each warning is printed once per server for each distinct problem. Rejections by the API are listed under Recent problems in the SDK page's Debugger. See remote configuration and delivery.

#Funnel steps

A funnel step is a reserved $funnel event, made for multi-step flows such as onboarding or a tutorial. Funnel steps need a player.

Analytics:TrackFunnel(player, "Tutorial", "Started", 0)
Analytics:TrackFunnel(player, "Tutorial", "Step2", 1)
Analytics:TrackFunnel(player, "Tutorial", "Completed", 2)

-- The player may also come third:
Analytics:TrackFunnel("Tutorial", "Completed", player, 2)
Argument Type Rules
player Player Required. Without it: TrackFunnel(<funnel>): pass the player so the step can be attributed.
funnel string Non-empty; cut to 64 characters.
step string Non-empty; cut to 64 characters.
index number? Optional step number, rounded down. Keeps steps in order in the funnel builder. Must not be negative, or the API rejects the event.

In the funnel builder a step is written $funnel:<Funnel>:<Step>, for example $funnel:Tutorial:Completed. You can also build funnels straight from custom events, so TrackFunnel is a convenience, not a requirement.

#Progression

Progression events record a player starting, completing or failing a level, stage or challenge.

Analytics:TrackProgression(player, "start", "World1:Level3")
Analytics:TrackProgression(player, "complete", "World1:Level3", 870)
Analytics:TrackProgression(player, "fail", "World1:Level3")
Argument Type Rules
player Player Required.
status "start" | "complete" | "fail" Exactly one of these.
path string Cut to 128 characters. Use : to make a hierarchy, such as World1:Level3.
score number? Optional. Must be finite.

Any other arguments are dropped with TrackProgression(player, 'start'|'complete'|'fail', path, score?). In the funnel builder these events are $progression:start, $progression:complete and $progression:fail.

Funnel steps and progression aren't affected by the Custom events switch or by Blocked events. Those apply only to TrackEvent.

#Examples

#A round-based game

ServerScriptService/Rounds.server.luau
local Players = game:GetService("Players")
local Analytics = require(game.ServerScriptService.Analytics)

local function runRound(mapName: string)
	Analytics:TrackEvent("RoundStarted", { Map = mapName, Players = #Players:GetPlayers() })
	local started = os.clock()

	-- … play the round …

	Analytics:TrackEvent("RoundEnded", {
		Map = mapName,
		Seconds = math.floor(os.clock() - started),
	})
end

#Shop funnel

-- When the shop UI is opened through a server RemoteEvent:
Analytics:TrackEvent(player, "ShopOpened", { Source = "HUD" })

-- When the player selects a product:
Analytics:TrackEvent(player, "ProductViewed", { ProductId = productId })

With purchase tracking in place, the Shop conversion funnel template (ShopOpened → ProductViewed → $purchase:attempted → $purchase:completed) works straight away.

If a client tells the server something happened (for example "I opened the shop"), the server can't verify it. That is fine for UI events like ShopOpened, but never track currency, items or purchases from what a client says. See economy.