Setup
In this integration guide we will take you through the most important steps of instrumenting your game with the GameAnalytics GameMaker SDK.
Before you start
The SDK supports:
- Android
- iOS
- Windows x64
- macOS
- Linux x64
- HTML5
GameMaker 2024.2 or newer is required.
Install the SDK
Download the SDK from the GameAnalytics GameMaker repository. Releases ship a zip containing the three resources below.
The SDK is three resources:
GameAnalyticsExt(an extension): the native libraries, platform bridges and function declarations.GameAnalytics(a script):GameAnalytics.gml, the cross-platform GML API that dispatches to whichever backend the current platform uses.obj_gameanalytics(an object): drives the desktop HTTP bridge.ga_initialize()creates it for you, you never reference it yourself.
You need all three. Copy them into your own project, or open the sample project sample/sample.yyp, select the three resources and use Tools -> Create Local Package to create a .yymps file you can import elsewhere.
Leaving out obj_gameanalytics means nothing is uploaded on Windows, macOS or Linux. The SDK logs a message saying so when ga_initialize() runs rather than failing silently.
- Android: no extra steps. The extension injects the Gradle repositories and dependencies it needs when your project builds.
- HTML5:
GameAnalytics.jsand theGameAnalyticsExt.jsbridge ship with the extension and are included automatically. - iOS: the static library is bundled in the extension, no extra steps.
Integrate the SDK
Configure the SDK and call ga_initialize in the Create event of a persistent controller object. Configuration calls must happen before ga_initialize, and ga_initialize has to run from a Create or Room Start event, once a room is running:
// Create event of a persistent controller object
ga_configure_build("1.0.0");
ga_configure_resource_currencies(["gems", "coins"]);
ga_configure_resource_item_types(["lives", "boosts"]);
ga_initialize("YOUR_GAME_KEY", "YOUR_GAME_SECRET");
Call ga_on_quit() in that same object's Game End event so the SDK can wrap up its session:
// Game End event
ga_on_quit();
Don't have any keys yet? Head over here and register your game at the GameAnalytics website!
Desktop HTTP bridge
On Windows, macOS and Linux the native library routes its uploads through GameMaker's own http_request instead of linking cURL and OpenSSL. That needs an instance to receive the Async HTTP event, so ga_initialize() creates the persistent obj_gameanalytics object, which issues the queued requests every step, hands the responses back to the SDK and stops waiting on any in-flight request when the game ends.
There is nothing to wire up: ga_initialize() starts the bridge and ga_on_quit() in your Game End event closes the session behind it. Android, iOS and HTML5 do not use it, the native SDK does its own networking there.
Sending events
Once the SDK is initialized you can start sending events from anywhere in your game:
ga_add_design_event("Game:Start");
Head over to the Event Tracking page for the full list of event types and their arguments.