Using GameAnalytics on Roblox

I rewrote my GameAnalytics module from ages ago to make it a little easier to use and included some preset functions to make it easier to track players.

Basic Info

This module by default tracks players joining, players leaving, developer product purchases and gamepass purchases (ones that are made in-game, if a player buys a gamepass on the website it won’t track it). It also tracks what platform the player is on (desktop, console or mobile), how many times they’ve played and how many transactions they made in-game. If you want to track anything else, like how many times a player died or how much money they earn/spend, you can use custom events. Learn how to do that at the bottom of the post.

How to setup

Step 1

Take the module from here: GameAnalytics Module V3 - Roblox and insert it into ServerStorage. You don’t want the client having access to the module at all because why would you

Step 2

Go to and make an account if you haven’t already. Once you make an account, add a game to it and get the GameKey and SecretKey from it because you will need those (

How to get GameKey and SecretKey once you added the game


Step 3

Once you have it in ServerStorage, put a script in ServerScriptService. Put this code in that script it makes it work:

local GameAnalytics = require(game.ServerStorage.GameAnalytics)
GameAnalytics:Init("PasteYourGameKeyRightHere", "AndPasteYourSecretKeyHere")

Step 4

That’s pretty much it set up now you can call GameAnalytics:SendEvent() to send custom events or if your more basic you can use the preset functions and here is an example of that (again this is already included in the module). If you decide to use the presets, sessions and transactions are already tracked and saved you just need to slightly modify the Presets module inside the GameAnalytics module if you want to save some other stuff it’s pretty easy.

There’s a premade server script and client script in the Module now, you can read it to find out how to properly set it up. It tracks what platform the player is on (desktop, console or mobile) and tracks developer product and gamepass purchases made in-game.

And here is how to send custom events

	["category"] = "design",
	["event"] = "Game:RoundStart",
	["value"] = 1,	

If you want a custom event to be tied to a specific player, just pass the player object as the second argument and it’ll automatically fill in the data.

	["category"] = "design",
	["event"] = "Game:KilledPlayer",
	["value"] = 1,	
}, game.Players.PlayerThatKilledSomeone)

If you find any bugs or something that’s wrong or there is something you want added just lmk and i’ll probably add it in


  • Added automatic error reporting on the server. You could add client error reporting aswell but it could be spammed so I wouldn’t recommend it. If you do decide to you can just call GameAnalytics:ReportError(ErrorMessage)

You will probably want to add:

if not game:GetService("RunService"):IsStudio() then
-- then run the module

So that its not doing anything in studio when you do testing in either play solo or server tests.

But thanks for this tutorial! I have been meaning to add some form of analytics just wasn’t sure how to go about doing that until now. Previously I been using datastore for some stuff temporarily. :smile:


You could also do something like

if game:GetService("RunService"):IsStudio() then
    GameAnalytics:Init("UseSandboxGameKey", "UseSandboxSecretKey", true)
    GameAnalytics:Init("UseRealGameKey", "UseRealSecretKey")

Setting the third parameter to true makes the module use sandbox mode so it won’t affect your actual game stats. You can get the sandbox keys here (you might have to log in idk)


Expect to be getting a cease and desist from me shortly…

In all seriousness though, cool tutorial. I look forward to seeing how you tracked gamepasses and dev products without sinking the purchase event, thought you could only have on listener for that.

1 Like

Yeah I wish they made ProcessReceipt an event instead of a callback but whatever. Rn the dev has to modify either the ProcessReceipt thing in the given server script or they have to manually track themselves.

As for gamepasses, I’m just using this which is an event so it works fine

Use this:

Ignore the warning, it’s completely wrong last I checked.

1 Like

Does this track sessions properly when players teleport between places in a game? I’m gonna take a look at this in the morning and consider seeing it up.

Nope but you could make it do this easily enough I think

You have this:

:PlayerJoined(Player Player)
 :PlayerRemoved(Player Player))
 :RecordTransaction(Player Player, string ID, number RobuxSpent)
 :SavePlayerData(Player Player)

Couple of quesitons.

  1. What is the second ‘Player’ argument for in the function? and for the RecordTransaction, what’s the string id?

EDIT Just going through some of the script, and noticed this small problem

local USDSpent = math.floor( (RobuxSpent * 0.7) * 0.35)

I believe 0.35 should be 0.0035, as if we changed ‘RobuxSpent’ to 100,000 Robux, then do the equation,

(100000*0.7)*0.35 = $24,500USD, which is widely innacurate

It’s supposed to be 0.35 cus GameAnalytics wants the amount in cents not USD

Wdym the second player argument? It’d just be something like this:
:RecordTransaction(game.Players.Player1, DevProduct:100Cash”, 10)

Got an error in the serveranalytics script last line:


x is unkown value

Another error

And now it’s also printing that I have given an invalid Secret Key, even tho I 1. copied and pasted it 4 times over and eventually went through every single number and letter over a dozen times, and it’s 100 correct

Ok so I cleared everything, deleted all the scripts and started again. This time copying down every single bit you had written, everything. I have not added anything to the scripts, just put in my keys and put them in the specified spots. Here’s what I got:

Don’t know why it’s firing the RecordTranscation function either, I literally just spawn in the game, don’t buy anything.


nvm I figured it out myself. The process receipt event was firing before the data had been loaded.

is this still working? I’m looking for a very simple wrapper for GameAnalytics