I’m barely scratching the surface of the capabilities of Game Analytics. This module will allow all functionality of GameAnalytics to be used, and I’ll leave links so clever people can go do that
This is a long tutorial but all the steps are super easy, and for most capabilities, very little scripting knowledge is needed
Set Up . . .
Okay, step 1, get my analytics module!
Okay, once you’ve done that, put it in a game, preferably a blank baseplate whilst you get use to this.
The only thing I want you to do right now is to go to the first line of the module and change it somewhere in replicated storage when I can put events and you won’t delete them or what ever (You can probably just leave it if you want)
Make sure HTTP service is enabled!!
Okay, so the next step is to go to GameAnalytics and create an account. Then do the following
-
Get rid of the annoying “Download an SDK” thing, lol no one integrates Roblox support by default so that’s not for us
-
Go to your email and verify your account and follow that line
-
Create a game (this is blindingly obvious but the picture to text ratio is low) and press the orange text which says “My game is not available in an app store”, Roblox doesn’t count :c
-
Name your game and press “Other” for the platform it’s on
-
Add benchmarks genres, they are mostly mobile games to compare yours to, and so not a great comparison but I get a kick out of it
- Next you should have a screen like this (if you don’t uhhh, well done you). Look at the Game Key And Secret Key. Don’t give this out to people!! (iCool Studio’s game Herp De Derp is an exception). Anyways, take this codes and copy and paste them to something.
Then click the skip guide button, and set up is complete!
Doing stuff!
So uhhh, GameAnalytics and me did pretty much all the heavy lifting in this area
However, the first thing you need to do is somewhere on the server write
Analytics = require(game.ReplicatedStorage.AnalyticsModule) -- The module doesn't have to be here
Analytics.ServerInit() -- Call THIS ONCE IN THE ENTIRE GAME!!!!!!!
And then, between the two brackets for ServerInit, insert the GameKey, and the SecretKey, in that order!!!
Analytics = require(game.ReplicatedStorage.AnalyticsModule) -- The module doesn't have to be here
Analytics.ServerInit("d39c482fd8604b680a7f5440b8e60286", "80d0dd29e81cfbd34c4b4536ffd1b095894e5568") -- Call THIS ONCE IN THE ENTIRE GAME!!!!!!!
Then on a client, and this needs to run very close to the client joining, preferable straight away
Analytics = require(game.ReplicatedStorage.AnalyticsModule) -- The module doesn't have to be here
Analytics.ClientInit() -- Call THIS ONCE PER CLIENT!!!!!
This code right here will give you full analytics for retention, playtime and some other stuff. Whilst your testing it and setting it up, I recommend opening up the module (spoopy!!) and going to line 5, and decrease it to around 1. This is how long it waits to send you events, and so when you’re debugging it’ll take less time for the events to start to send so you don’t have to hang around for a minute waiting for it to stuff.
Finding your visit
To verify that worked, go to Realtime (top left) to verify it worked, it takes 15 minutes to process on small games, and 45 minutes if the site is having a slow down or what ever
Finding your analytics . . .
The code I gave you will populate the following places:
-
Retention benchmarks - It’ll also do time benchmarks found in the bottom corner(Found by going to Dashboards > Benchmarks)
-
Engagement (Found by going to Dashboards > Engagement)
N.B Because of Roblox, acquisition is not accurate so uhhh, don’t use that.
Monetisation Analytics
To record money stuff, I wrote a super special function for you. Just write
Analytics = require(game.ReplicatedStorage.AnalyticsModule)
Analytics.RecordTransaction(Player, Price, Thing)
The player should be the player object, the price is a int value in ROBUX
About “Thing”, that should be a string value. It offers classes of item. The way it should work and is formatted is “Catagory:Specific”, so if I sell pets the catagory is Pet, and the Specific is a dragon, if a dragon has just been brought.
Just to clarify, in NONE of the string arguments (the ones which are plain text), don’t put a space that’ll break it.
Analytics = require(game.ReplicatedStorage.AnalyticsModule)
Analytics.RecordTransaction(Player, 500, "Pet:Dragon")
Analytics.RecordTransaction(Player, 1000000, "Pet:UhhhNotADragon")
Analytics.RecordTransaction(Player, 1.5 * 10 ^ 1000, "Sword:Derp") -- Idk if you can send events in standard form plz don't try
Analytics.RecordTransaction(Player, 9999999999999999999999, "Starterpack")
Note that you can do “catagory:subcatagory:subcatagory:thing”. Not limit to how many subcatagorys you have, and it is not compulsory to have a catagory at all as shown in the starterpack example
If you want it to record it in USD or deduct the tax (or both), still pass the arguments in USD and don’t do anything weird with it. Just open up the module, and in Settings (right at the top), just set ApplyTax and ConvertedToUSD to true or false
And this will populate a bunch of other stuff such as (All can be found under Dashboards>Monetisation):
Sending Resource Flow Events
First, what is a resource flow event? What it is, is when a player in your game loses or gains a currency. And game analytics allows you to track this, and the sources and sinks of your currency. How kind of them!?
I have also provided an inbuilt API to do this for you, how kind of me!?
Here is the data you must provide:
Analytics.RecordResource(Player, Amount, FlowType, Currency, ItemType, ItemId)
So lets talk about what they are.
-
Player is the player object, fairly obviously.
-
Amount is a number value which denotes how much currency has been spent or earnt. Stick to sending integers
-
FlowType is a string value, and must either be “Sink” or “Source”. Source if they are earning money, Sink if they are losing it.
-
Currency is a string value which denotes the ingame currency used. For example “Gems” or “Gold”
-
ItemType is quite hard to understand. It’s what type of thing gave them the money, or the what type of item they spent it on. So this could be a mission giving it to them, or a gun they’re spending it on. The rule about no spaces applys here.
-
ItemId is what specifically you sent. So if you set a mission to be the ItemType, you might say “KillZombies”, or if it was a gun, you might put “M4A1”
More on ItemId
Much like with revenue, you can go deeper with item type. To do that here, expand ItemId. So for example you might want it to be a KillZombies mission on hard, you’d set ItemId to be “KillZombies:Hard”
Resource analytics is a little hard to understand at first, so I took the game analytic’s website examples and Lua-fied them (yes that’s the technical term)
Examples
Example 1: Life used to play level.
Analytics.RecordResource(Player, 1, “Sink”, “Life”, “continuity”, “startLevel”)
Example 2: Gold spent to buy rainbow boost
Analytics.RecordResource(Player, 50, “Sink”, “Gold”, “Boost”, “Rainbow”)
Example 3: Gold spent to buy big rainbow boost
Analytics.RecordResource(Player, 100, “Sink”, “Gold”, “Boost”, “Rainbow:Big”)
Example 4: Earning gold by doing a zombie killing mission
Analytics.RecordResource(Player, 100, “Source”, “Gold”, “Mission”, “ZombieKilling”)
Example 4: Earning gold by doing a hard doggo killing mission
Analytics.RecordResource(Player, 1337, “Source”, “Gold”, “Mission”, “DogeCleansing:Hard”)
Sending Other Events
To find the API for this, go here: GameAnalytics Collector REST API Reference
Code example of how to do this:
Analytics = require(game.ReplicatedStorage.AnalyticsModule)
Analytics.ServerEvent(
{
["category"] = "resource";
["event_id"] = "Sink:Gems";
["amount"] = 100000;
},
Player
)
Analytics.ServerEvent(Event, Player)
It’s self explanatory when you read their notes. Just a note about ServerEvent function. Mobile Analytics assumes there will always be a player, but if you leave the Player bit blank, it’ll send it as a random player. There must be a player tied to all events.
Okay, peace my dudes.
PSA: This was updated recently! Find the updates here
- Added automatic error reporting. Partial credit to @rcouret
- Added better platform detection. Total credit to @Velibor (literally copied and pasted his code. worked great, thanks!)
- Added events being submitted on game shutdown. Partial credit to @Tim7775
- Added huge performance bonuses. Total credit to @Widgeon
- Improved security. Thanks to @Merely for pointing this out.
- Added settings to convert to USD, deduct tax, and change intervals between events being submitted.
- Added in-built functionality to send resource events (see above)
- Improved in-built debugging prints