Introduction

In this tutorial, we’ll show you exactly how we did this ourselves, using a game that we built in our spare time: a hyper casual title called Swivel 2D.

After adding our SDK into your game you’ll start seeing loads of really useful insights.

If you want to get even more granular with custom tracking options, you’ll need to add some manual calls. Don’t worry, it’s pretty easy to do.

Yup, the game actually exists on Android and iOS. Download and give it a play today!

Swivel 2D Tutorial

About the game

Swivel 2D is a simple mobile game with intuitive mechanics. To play, all you need to do is either drag or tap on the screen to position a red and blue circle, making sure to collect matching colors and avoid killer obstacles.

The game has 10 predefined levels, 2 different control schemes, and IAP for virtual currency (which you can use to purchase extra lives).

Swivel 2D Gameplay

What do we need?

Important KPIs like DAU and Session Length are available on integration but, just like you, we want more granular insights.

Examples include: more detail on level difficulty and where players stick, how players interact with the game UI, and how much money or virtual currency is spent. We can achieve this by calling the following event types in the game:

Event Type Purpose Examples
Progression Level Attempts Level 10, Stage End, Tutorial Complete
Business In-App Purchases Booster, Remove Ads, New Skill
Resource Virtual Currency Lives, Gems, Gold, Elixir, Rupies
Design Custom Events Tap, Swipe, Bomb, Mine, Social Connect

SDK Integration

We built this game in the Unity game engine. We’ve created detailed setup guides for all GameAnalytics SDKs. You can find them here.

  1. First we include the files into the project
  2. Then we sign up to GameAnalytics and create our game
  3. Once completed we get a game key and secret key
  4. Enter these keys into the GameAnalytics object UI in the Unity project editor
  5. And, finally, we initialize the SDK

GameAnalytics Integration Unity

Levels (Progression)

We want to gain insight into how the levels are played and how difficult players are finding them.

To get this insight, we use the progression event to track when a level attempt starts and when it either completes or fails. We do this by sending the level name along with an optional value (like a level score), on level end.

Code example
												
/ It is possible to track a level hierarchy (like “world, stage, level”), but our structure is simple.
// Start the level
GameAnalytics.NewProgressionEvent(GAProgressionStatus.Start, "Level_1")
// End the level (player completes it with a level score of 10)
GameAnalytics.NewProgressionEvent(GAProgressionStatus.Complete, "Level_1", 10)

												
											

In-App Purchases

When users spend money, we want to make sure that all IAP are validated so that business events from hacked games do not skew the revenue tracking with false transactions.

The IAP can trigger from the menu, or when the user dies on a level. The amount tracked is in cents (99 = 0.99$). In Unity, we call the following business event straight after a successful IAP. The SDK then receives the digital receipt, which is then sent to our backend for validation, resulting in valid revenue numbers.

												
/When the user gets a life we call the following
GameAnalytics.NewResourceEvent (GAResourceFlowType.Source, “life”, 1, “Consumable”, “life-1”);
// We call this when a player spends a life to continue when dying on a level
GameAnalytics.NewResourceEvent (GAResourceFlowType.Sink, “life”, 1, “Consumable”, “life-1")


												
											

Virtual Currency (Resources)

When the user performs an IAP they get a bunch of virtual currency that we call “lives”. The player can spend 1 life to continue playing when they fail a level.

We want to track when users get new coins (source) and when they spend those coins (sink). We do this by using a resource event.

												
//99 means $0.99
#if (UNITY_IOS)
// iOS - with autoFetchReceipt
GameAnalytics.NewBusinessEventIOSAutoFetchReceipt (“USD”, 99, “Consumable”, “1000credits”, “shop”);
#endif
// Android - Google Play
// Retrieve receipt & signature manually in Base64 encoding
#if (UNITY_ANDROID)
GameAnalytics.NewBusinessEventGooglePlay (“USD”, 99, “Consumable”, “1000credits”, “shop, “+RECEIPT+”, “+SIGNATURE+”);
#endif


												
											

Custom Events (Design)

We have some special tracking needs that are not covered by any predefined event type. This is a very normal situation, as most games have unique elements worked into the gameplay core loop which are fundamental to the player experience.

We use the following design event that provides an “event_id” with a hierarchy and value.

													
	// The game can be played by either tapping or swiping. After tutorial the user is asked for preference.
	GameAnalytics.NewDesignEvent("Tutorial:Tap");
	// or.. 
	GameAnalytics.NewDesignEvent("Tutorial:Swipe");

	// Users can skip tutorial
	GameAnalytics.NewDesignEvent("Tutorial:Skip");
													
												

This concludes the integration steps!

Dashboards

Once we have the game deployed we can check the data live on the real-time dashboard. There are many other predefined dashboards displaying all the basic KPIs needed.

We want a dashboard for tracking our custom design events and other metrics we find important. To do this we create a custom dashboard and add all the widgets we need, like DAU by country, revenue, distribution of tap vs. swipe controls etc.

GameAnalytics Dashboard

Explorer tool

To dig even deeper into our data we use the Explorer Tool in order to specify more options and select visualizations. We can also compare trends directly between 2 different metrics like DAU and revenue.

GameAnalytics Explore Tool

...and there is more!

We provide so much more and you can easily experience all this yourself. Sign up and get instant access to a demo-game, where you can preview all of our features.

Funnels Email reports
Cohorts Experiments (A/B testing)
Command Center Benchmarks
Segments User acquisition

Here’s a full breakdown of all the GameAnalytics features.