Using Google Analytics in Roblox
Using Google Analytics in Roblox
The work of a Roblox game developer doesn’t stop after a game is published. Bugs which didn’t appear during testing may emerge, players will respond to design aspects in ways you never imagined, and new features will need to be added over time.
One way to monitor your game post-launch is through
articles/introduction to analytics|analytics, using tools such as Google Analytics.
Getting a Tracking ID
To analyze aspects of your game using Google Analytics, you’ll need a tracking ID, a unique number that can be shared between all places in your game. If desired, you can later generate additional tracking IDs for other games.
Once you sign up for a Google Analytics account, supply the following information:
|Account Type||Select Website as the account type to track (data is analyzed through this type even for cross-platform Roblox games).|
|Account Name||Since one account can hold multiple tracking IDs for multiple games, enter a non-specific name like "Roblox Games."|
|Website Name||Also referred to as Property Name, this basically describes what you're planning to analyze. If you're most interested in tracking one place in a game, a place-specific name like "Game Lobby" or "Race Track 1" may be appropriate. If you want to track multiple places, the game's title might be better. Note that you can change this name later, as well as add additional properties.|
|Website URL||Enter any valid web address (the site itself will not be tracked).|
The remaining info is not pertinent to how Roblox uses Google Analytics, so only supply the other details as you feel appropriate.
When you’re ready, click Get Tracking ID. This will lead to a page containing the new tracking ID in this format:
Using a Tracking ID
Enabling HTTP Requests
To use Google Analytics in a Roblox game,
HttpService must first be enabled:
- In Roblox Studio, click on Game Settings in the Home tab.
- In the Options tab of the popup window, enable the Allow HTTP Requests option. Remember to click Save to store your preference.
Tracking a Place
To start tracking actions and events in a place, follow these simple steps:
- Create a new server
- Paste the following lines into the script.
- Replace the
UA-#########-#with the tracking ID obtained earlier. That’s it; your place will now be tracked by Google Analytics!
If you want a more fine-tuned approach, you can also pass a
config table to the
Google Analytics Basics
This article cannot outline detailed usage of Google Analytics (please consult the in-platform help), but these guidelines should get you started.
Once you have the tracking ID set up for a place, it’s easy to see real-time statistics.
- Publish your game to Roblox to make sure the new
Scriptis added with your tracking ID.
- Start playing within the place you’re tracking, either in Roblox Studio or the Roblox application itself.
- On the Google Analytics page, expand the Real-Time menu on the left.
- Click on the Events sub-item to reveal a graph showing events as they happen in your game. You should see new events like ServerStartup and Visit in the charts and tables, assuming you didn’t disable them via a
configtable in your script. If your game has any Lua errors, they will also show in the chart when the error occurs.
You can also see a history of events by clicking Behavior → Events. This shows all tracked events over time with many ways to filter the data and analyze trends. For example, the following Overview page shows the total events along with relevant data. Clicking on Event Action shows the actions of ServerStartup and Visit, each of which can be expanded to reveal further details.
Reporting Custom Events
Roblox’s integration of Google Analytics allows you to report custom in-game events, including anything from players finding a secret treasure room to how often they use one item/object over another.
To report custom events to Google Analytics, use the
ReportEvent() function of the
GA module that was initialized in the example
As indicated, the
GA.ReportEvent() call requires four parameters:
||The default value is
||This value will appear in Google Analytics as Event Action, as seen with Visit in the screenshot above. This may be used to identify a specific action related to a category, for example
||This value will appear as Event Label in Google Analytics and it can be used to define a specific detail about a category or action. For instance,
||This parameter lets you define a specific value associated with the event. For example, you could keep count of how many times a player who equips an item actually uses it, then report that value to Google Analytics with an
As you can see, analytics let you fine-tune your game and elevate the player experience. Now that you understand how to connect Google Analytics to your game, explore fundamental concepts of analytics in our
articles/measuring engagement|Measuring Engagement and
articles/designing for engagement|Designing for Engagement guides.