PcoWSkbVqDnWTu_dm2ix
We use cookies on this site to enhance your user experience

Using Google Analytics in Roblox

Using Google Analytics in Roblox

Nov 16 2018, 12:20 PM PST

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 of the best ways to monitor and improve 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:

Item Guidelines
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:

  1. In Roblox Studio, click on Game Settings in the Home tab.
  1. 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:

  1. Create a new server Script within ServerScriptService.
  2. Paste the following lines into the script.
local GA = require(153590792)
GA.Init("UA-#########-#")
  1. 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 GA.Init() function:

local config = {
	-- Report or omit script errors (set as 'true' to omit)
	DoNotReportScriptErrors = false
	-- Report or omit a 'ServerStartup' action when a server starts (set as 'true' to omit)
	DoNotTrackServerStart = false
	-- Report or omit player visits under the 'Visit' action (set as 'true' to omit)
	DoNotTrackVisits = false
}

local GA = require(153590792)
GA.Init("UA-#########-#", config)

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.

Real-Time Events

Once you have the tracking ID set up for a place, it’s easy to see real-time statistics.

  1. Publish your game to Roblox to make sure the new Script is added with your tracking ID.
  2. Start playing within the place you’re tracking, either in Roblox Studio or the Roblox application itself.
  3. On the Google Analytics page, expand the Real-Time menu on the left.
  4. 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 config table in your script. If your game has any Lua errors, they will also show in the chart when the error occurs.

Historical Behavior

You can also see a history of events by clicking BehaviorEvents. 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 Script above:

local GA = require(153590792)
GA.Init("UA-#########-#")

local category = "PlaceId-" .. game.PlaceId
local action = "Category-Action"
local label = "none"
local value = 1

GA.ReportEvent(category, action, label, value)

As indicated, the GA.ReportEvent() call requires four parameters:

Parameter Description
category The default value is "PlaceId-" .. game.PlaceId, yielding a string like PlaceId-5432167890, but you can specify a more descriptive category like "GameItemActions".
action 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 "GameItemActions" might have an action value of "Equipped".
label 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, "GameItemActions""Equipped" may be labeled with the actual item that was equipped such as "Ice Wand".
value 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 action value of "TimesUsed", helping you understand if players enjoy using the item.

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.

Tags:
  • analytics
  • retention
  • marketing