v2.0Last updated: Feb 2026

BloxMetrics SDK

The complete analytics SDK for Roblox games. Track players, revenue, economy, progression, and errors — all with a single require() call.

Player Sessions
Revenue
Economy
Progression
Error Tracking
Custom Events
Funnels
Retention
local BM = require(127217366828209)

Installation

Set up BloxMetrics in 4 steps. No files to download, no packages to install.

1

Enable API access in your game

In Roblox Studio, go to Game SettingsSecurity → enable "Enable Studio Access to API Services". This is required for the SDK to send data.

2

Get your API key

Go to your BloxMetrics Dashboard → select your game → Settings → copy the API key.

3

Create a Script in Roblox Studio

In the Explorer panel, create a new Script inside ServerScriptService. Name it BloxMetrics.

4

Paste the code and publish

Copy the code below, paste it into the script, replace YOUR_API_KEY with your actual key, and hit Publish. That's it!

Paste this into your script:

ServerScriptService → BloxMetricsFull setup
lua
local BM = require(127217366828209)

BM:Init("YOUR_API_KEY")
  :EnablePlayerTracking()    -- sessions, devices, countries (automatic)
  :EnableRevenueTracking()   -- gamepass purchases (automatic)
  :EnableEventTracking()     -- custom events
  :EnableErrorTracking()     -- Lua errors (automatic)

-- ✅ Done! Data will appear in your Dashboard within 60 seconds.
Important: You must enable "Enable Studio Access to API Services" in your game settings (Game Settings → Security). Without this, the SDK cannot send HTTP requests and no data will appear in your dashboard.
Server-side only. Place this script in ServerScriptService, never in a LocalScript. Your API key is never exposed to players.

Quick Start

After pasting the code, hit Play in Roblox Studio. Data will start appearing in your Dashboard within 30–60 seconds.

Player join & leaveauto
Session durationauto
Device type (PC / Mobile / Console)auto
Country & regionauto
New vs returning playersauto
GamePass purchasesauto
Lua error logsauto
DAU / MAU metricsauto
Everything above is tracked automatically via Enable*() — no extra code needed.

API Key

Each game has its own API key. Find yours here:

DashboardSelect gameSettingsAPI Key
Never share your API key. Only use it inside ServerScriptService scripts. If placed client-side, anyone can write data to your account.

Init & Config

BM:Init() must be called before anything else — usually the first line of your script.

BM:Init(apiKey: string, options?: table) → self
ParameterTypeDescription
apiKeystringYour API key from the BloxMetrics Dashboard
optionsoptionaltableOptional settings (e.g. debug mode)
With debug mode
lua
BM:Init("bm_live_abc123", {
    debug = true,  -- prints SDK logs to the Output window
})
Enable debug = true while testing — you'll see every SDK request in the Output window. Remove it before publishing to production.

Player Tracking

BM:EnablePlayerTracking() → self

Automatically tracks player sessions, devices, countries, and retention. Zero config required.

Auto-tracked data:

Session start & end
Session duration
Device type (with client script)
Country / region
Platform (desktop/mobile/console)
New vs returning players
DAU / MAU metrics
Retention (D1, D7, D30)

Player Properties

Attach custom data to players for segmentation and filtering in the dashboard.

BM:SetPlayerProperty(player, key, value) → void
BM:IncrementPlayerProperty(player, key, amount?) → void
BM:GetPlayerProperty(player, key) → any
ParameterTypeDescription
playerPlayerThe player instance
keystringProperty name
valueanyProperty value
amountoptionalnumberIncrement amount (default: 1)
Player Properties
lua
-- Set properties on join
Players.PlayerAdded:Connect(function(player)
    BM:SetPlayerProperty(player, "level", 1)
    BM:SetPlayerProperty(player, "clan", "none")
    BM:SetPlayerProperty(player, "vip", false)
end)

-- Increment on events
BM:IncrementPlayerProperty(player, "kills", 1)
BM:IncrementPlayerProperty(player, "coins_earned", 50)

-- Read
local level = BM:GetPlayerProperty(player, "level")

Revenue Tracking

BM:EnableRevenueTracking() → self

Automatically tracks GamePass purchases via MarketplaceService.PromptGamePassPurchaseFinished. For Developer Products, use HandleProcessReceipt.

BM:TrackPurchase(player, productId, productName?, robuxAmount?, productType?) → void
ParameterTypeDescription
playerPlayerThe buyer
productIdnumber|tableProduct ID or table with fields
productNameoptionalstringDisplay name
robuxAmountoptionalnumberPrice in Robux
productTypeoptionalstring"gamepass" | "devproduct" | "subscription"
Manual purchase tracking
lua
-- Manual tracking (if not using HandleProcessReceipt)
BM:TrackPurchase(player, 12345, "VIP Pass", 499, "gamepass")

-- Or pass a table:
BM:TrackPurchase(player, {
    productId = 12345,
    name = "100 Coins",
    robux = 25,
    type = "devproduct",
})

Process Receipt

BM:HandleProcessReceipt(products: table) → void

Replaces MarketplaceService.ProcessReceipt. Handles receipt validation, purchase tracking, and your reward logic in one place.

Developer ProductsRecommended
lua
BM:HandleProcessReceipt({
    -- Product ID → handler
    [111111] = {
        name = "100 Coins",
        handler = function(player)
            -- Your reward logic:
            PlayerData:AddCoins(player, 100)
            BM:TrackSource(player, "Coins", 100, "iap", "100_coins_pack")
            return true  -- must return true to confirm
        end,
    },
    [222222] = {
        name = "VIP Boost",
        handler = function(player)
            PlayerData:ActivateVIP(player)
            return true
        end,
    },
})
Each handler must return true to confirm the purchase. Returning false or erroring will retry the receipt later.

Economy Tracking

BM:EnableEconomyTracking(currencies: {"Coins","Gems",...}) → self

Track in-game currency flow — sources (earning) and sinks (spending). Monitor inflation, find balancing issues.

BM:TrackSource(player, currency, amount, itemType, itemId?) → void
BM:TrackSink(player, currency, amount, itemType, itemId?) → void
ParameterTypeDescription
playerPlayerThe player
currencystringCurrency name (must be in EnableEconomyTracking list)
amountnumberAmount earned/spent
itemTypestringCategory: "quest", "shop", "iap", "combat", etc.
itemIdoptionalstringSpecific item identifier
Economy Examples
lua
BM:EnableEconomyTracking({ "Coins", "Gems", "Tickets" })

-- Sources (player EARNS currency)
BM:TrackSource(player, "Coins", 100, "quest", "daily_quest_1")
BM:TrackSource(player, "Coins", 50,  "combat", "kill_reward")
BM:TrackSource(player, "Gems",  10,  "iap", "starter_pack")

-- Sinks (player SPENDS currency)
BM:TrackSink(player, "Coins", 500, "shop", "speed_potion")
BM:TrackSink(player, "Gems",  25,  "gacha", "legendary_crate")

Progression Tracking

BM:EnableProgressionTracking() → self

Track level/stage/mission completion, failure rates, and difficulty hotspots. Supports up to 3 hierarchy levels.

BM:StartProgression(player, p1, p2?, p3?) → void
BM:CompleteProgression(player, p1, p2?, p3?, score?) → void
BM:FailProgression(player, p1, p2?, p3?, score?) → void
ParameterTypeDescription
playerPlayerThe player
p1stringTop level: "World1", "Tutorial", "Season2"
p2optionalstringMid level: "Stage3", "Chapter1"
p3optionalstringBottom level: "Level5", "Boss"
scoreoptionalnumberScore/rating on complete/fail
Progression Examples
lua
-- Simple: tutorial
BM:StartProgression(player, "Tutorial")
BM:CompleteProgression(player, "Tutorial")

-- 2-level: world + stage
BM:StartProgression(player, "Enchanted Forest", "Stage 3")
BM:FailProgression(player, "Enchanted Forest", "Stage 3", nil, 2500)

-- 3-level: world + stage + level
BM:StartProgression(player, "World1", "Zone3", "Boss")
BM:CompleteProgression(player, "World1", "Zone3", "Boss", 9800)

Custom Events

BM:EnableEventTracking() → self
BM:TrackEvent(player, eventName, eventData?) → void
ParameterTypeDescription
playerPlayerThe player
eventNamestringEvent name (snake_case recommended)
eventDataoptionaltableOptional key-value metadata
Custom Events
lua
-- Simple event
BM:TrackEvent(player, "shop_opened")

-- With metadata
BM:TrackEvent(player, "item_purchased", {
    item = "Golden Sword",
    cost = 500,
    currency = "Coins",
})

BM:TrackEvent(player, "boss_defeated", {
    boss = "Dragon King",
    time = 45.2,
    deaths = 3,
})

Funnels

BM:TrackFunnelStep(player, funnelName, stepNumber, stepName) → void

Track conversion funnels — onboarding, shop flow, tutorial completion, etc. View drop-off rates in the dashboard.

ParameterTypeDescription
playerPlayerThe player
funnelNamestringFunnel identifier: "onboarding", "shop_flow"
stepNumbernumberStep number (1, 2, 3...)
stepNamestringHuman-readable step name
Funnel Example
lua
-- Onboarding funnel
BM:TrackFunnelStep(player, "onboarding", 1, "game_opened")
BM:TrackFunnelStep(player, "onboarding", 2, "tutorial_started")
BM:TrackFunnelStep(player, "onboarding", 3, "tutorial_completed")
BM:TrackFunnelStep(player, "onboarding", 4, "first_purchase")

-- Shop flow
BM:TrackFunnelStep(player, "shop_flow", 1, "shop_opened")
BM:TrackFunnelStep(player, "shop_flow", 2, "item_viewed")
BM:TrackFunnelStep(player, "shop_flow", 3, "purchased")

Design Events

BM:TrackDesign(player, eventId, value?) → void

Hierarchical events for game design analysis. Use colon-separated IDs for grouping.

Design Events
lua
-- Weapon usage tracking
BM:TrackDesign(player, "Combat:Kill:Sword", 1)
BM:TrackDesign(player, "Combat:Kill:Bow", 1)

-- Map interaction
BM:TrackDesign(player, "Map:Zone:Entered:Forest", 1)

-- Gacha results
BM:TrackDesign(player, "Gacha:Premium:Legendary", 1)

Error Tracking

BM:EnableErrorTracking(options?) → self

Automatically captures Lua errors with stack traces. You can also manually log errors with severity levels.

BM:TrackError(player, severity, message) → void
ParameterTypeDescription
playerPlayer|nilAssociated player (nil for server errors)
severitystring"critical" | "error" | "warning" | "info" | "debug"
messagestringError message
Error Tracking
lua
BM:EnableErrorTracking()  -- auto-captures Lua errors

-- Manual error tracking
local ok, err = pcall(function()
    -- risky DataStore operation
    DataStore:SetAsync(key, data)
end)

if not ok then
    BM:TrackError(player, "critical", "DataStore save failed: " .. tostring(err))
end

-- Warnings
BM:TrackError(player, "warning", "Player inventory near limit: " .. #inventory)

-- Server-wide errors (no player)
BM:TrackError(nil, "error", "Matchmaking service unavailable")
Auto-captured errors are tagged with auto_captured = true in the dashboard so you can distinguish them from manual reports.

Access Control

Tag players with access levels (VIP, premium, beta, admin) for segmentation in analytics.

BM:GrantAccess(player, level) → void
BM:HasAccess(player, level) → boolean
BM:RevokeAccess(player, level) → void
BM:GetAccessLevels(player) → table
Access Control
lua
-- Grant on gamepass ownership
if MarketplaceService:UserOwnsGamePassAsync(player.UserId, VIP_PASS_ID) then
    BM:GrantAccess(player, "vip")
end

-- Check
if BM:HasAccess(player, "vip") then
    -- give VIP perks
end

-- Revoke
BM:RevokeAccess(player, "beta_tester")

-- Get all levels
local levels = BM:GetAccessLevels(player)
-- → { "vip", "beta_tester" }

Identity

BM:Identify(player, customId) → void

Link a player to a custom ID (e.g., your own user system, external database ID).

Custom identity
lua
BM:Identify(player, "user_abc123")

Debug & Status

BM:SetDebug(enabled: boolean) → void
BM:IsInitialized() → boolean
BM:GetStatus() → table
BM:Flush() → void
Debugging
lua
-- Toggle debug logs
BM:SetDebug(true)

-- Check status
print(BM:IsInitialized())  -- true/false

local status = BM:GetStatus()
-- → { initialized = true, queueSize = 5, modules = {...} }

-- Force-send queued events (useful before server shutdown)
BM:Flush()

Full Example

A complete integration showing every feature. Copy what you need.

ServerScriptService → GameInitComplete
lua
local Players = game:GetService("Players")
local BM = require(127217366828209)

-- ═══ STEP 1: Initialize ═══
BM:Init("YOUR_API_KEY", { debug = true })
  :EnablePlayerTracking()
  :EnableRevenueTracking()
  :EnableEventTracking()
  :EnableEconomyTracking({ "Coins", "Gems" })
  :EnableProgressionTracking()
  :EnableErrorTracking()

-- ═══ STEP 2: Developer Products ═══
BM:HandleProcessReceipt({
    [111111] = {
        name = "100 Coins",
        handler = function(player)
            -- your reward logic
            BM:TrackSource(player, "Coins", 100, "iap", "100_coins_pack")
            return true
        end,
    },
})

-- ═══ STEP 3: Player Setup ═══
Players.PlayerAdded:Connect(function(player)
    BM:SetPlayerProperty(player, "level", 1)
    BM:TrackFunnelStep(player, "onboarding", 1, "game_opened")
end)

-- ═══ GAME LOGIC ═══

-- Level complete
local function onLevelComplete(player, world, stage, score)
    BM:CompleteProgression(player, world, stage, nil, score)
    BM:IncrementPlayerProperty(player, "levels_completed", 1)
    local reward = math.floor(score / 10)
    BM:TrackSource(player, "Coins", reward, "level_reward", stage)
end

-- Shop purchase
local function onShopPurchase(player, item, cost)
    BM:TrackSink(player, "Coins", cost, "shop", item)
    BM:TrackEvent(player, "item_purchased", {
        item = item, cost = cost,
    })
end

-- Safe DataStore save
local function safeSave(player, data)
    local ok, err = pcall(function()
        DataStore:SetAsync(tostring(player.UserId), data)
    end)
    if not ok then
        BM:TrackError(player, "critical", "Save failed: " .. tostring(err))
    end
end

print("[Game] BloxMetrics ready ✅")

Client Script(Optional)

For accurate device detection (desktop / mobile / console / VR), add this LocalScript to StarterPlayerScripts. Without it, device data defaults to platform detection.

The BloxMetricsRemotes folder is created automatically by the server SDK when you call EnablePlayerTracking(). You don't need to create it manually — just make sure the server script is running before this client script.
StarterPlayerScripts → BloxMetrics_ClientOptional
lua
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local UserInputService = game:GetService("UserInputService")
local VRService = game:GetService("VRService")

local remotes = ReplicatedStorage:WaitForChild("BloxMetricsRemotes", 10)
if not remotes then return end

local reportDevice = remotes:WaitForChild("ReportDevice", 5)
if not reportDevice then return end

local function getDevice()
    if VRService.VREnabled then return "vr"
    elseif UserInputService.TouchEnabled
        and not UserInputService.KeyboardEnabled then return "mobile"
    elseif UserInputService.GamepadEnabled
        and not UserInputService.KeyboardEnabled then return "console"
    else return "desktop"
    end
end

reportDevice:FireServer(getDevice())

Troubleshooting

Common issues and how to fix them.

No data appearing in the dashboard

Make sure "Enable Studio Access to API Services" is turned ON in Game Settings → Security. Without this, HTTP requests are blocked and no data can be sent.

HTTP 403 or "API key invalid" error

Double-check your API key in Dashboard → Game Settings. Make sure you copied the full key with no extra spaces. Each game has a unique key.

Device detection shows "unknown" for all players

Add the optional Client Script (LocalScript) to StarterPlayerScripts. The server SDK creates the BloxMetricsRemotes folder automatically — the client script just needs to be present.

Data appears in Studio but not in published game

After testing in Studio, make sure to Publish the game (File → Publish to Roblox). Also verify that API services are enabled for the published version, not just Studio.

Revenue/GamePass purchases not tracking

Ensure EnableRevenueTracking() is called in your init chain. For Developer Products, you must use BM:ProcessReceipt() as shown in the Revenue Tracking section.

SDK module not found / require() fails

Make sure you're using the correct Asset ID: 127217366828209. The require() call should be: require(127217366828209). Check that your game has access to load third-party modules.

Still stuck? Email us at hello@bloxmetrics.io and we'll help you get set up.

BloxMetrics SDK v2.0 • Asset ID: 127217366828209

Need help? Reach out at hello@bloxmetrics.io

Roblox Creator Store