Adding Google Analytics

screen

Every game should have analytics. You need to know your players and make a game that they love. Analytics will help you a lot. In ShooterTutorial example I would like to know:

  • Where player dies – if game is to hard or to easy,
  • Which weapons players are using,
  • Which weapons are the best,
  • Which patterns and enemies are hard and which are easy,
  • How many people is looking at leaderboards and other screens,
  • If players use combo to make better score,
  • If reloading times are to slow,
  • and lot more…

I will show you how quickly you can implement analytics in your game and in ShooterTutorial. We have great times for indie developers now.

This Tutorial has been created using Unreal Engine 4.10
Make sure you are working on the same version of the engine.

Google Analytics

I used many analytics backends in my work. For Unreal Engine 4 I was searching for something that is cross platform. Currently there is only one cross platform UE4 plugin that let you quickly add analytics using Blueprints. Created by fellow developers GameDNA from Poland.

Yes – it’s not free. I know that you guys are blaming me that I’m using premium assets. I want to support indie developers as I’m somehow indie as well. Another thing is that I haven’t found any free alternative.

BUT seriously 40$ for such plugin is cheap. You can spend weeks implementing your own backend for analytics. Buying this plugin will save you a lot of time and you will get source as well. Totally recommended. It’s working out of the box and it’s really easy to use it in Blueprints.

Preparation

You need to have Google Analytics account with tracking key for your website. Website here means your game. You game will be treated by Google as website.

account,

Make sure you have changed your DefaultEngine.ini to use GoogleAnalytics with your site:

config

My AnalyticsDevelopment and AnalyticsTest are disabled as I don’t want to record what I’m doing when playing in editor. I just want to record with cooked shipping build. For testing in Editor (Play In Editor, Play In Standalone) you should copy/paste Analytics to AnalyticsDevelopment and AnalyticsTest.

If you have plugin enabled you will have two new nodes:

blocks

One is for tracking where is player. (menu, ingame, main menu, settings etc) Second one is to send custom data. Yes only two new nodes which will give you a lot.

Before you start you need to use Start Session and End Session nodes. I have used ShooterGameInstance Init event to call Start Session and Event Shutdown to Close Session. It’s working like a charm but if you are testing in editor you won’t get Shutdown event in ShooterGameInstance. Try to use GameModes EndPlay instead when testing.

Where is player

First let’s track where is player. Thanks to Google I will be able to know how much time player spend in settings screen and where he goes after that. Make sure you are using Record Google Screen in places valuable for you. My list of screens:

  • None. Called in EndSession from GameMode – means before loading or error,
  • SummaryScreen,
  • SummaryScreen-Leaderboards,
  • Summary-Restart. Yes I’m tracking restart button because I would like to know where player goes from summary screen,
  • Summary-MainMenu. The same thing here,
  • Loading. When in Loading,
  • InGame. During ingame,
  • MainMenu
  • MainMenu-LevelSelection. When in level selection screen,
  • MainMenu-LevelSelection-Leaderboards. When in level selection screen but inside leaderboards,

Just use Record Google Screen node with those names. You can call this node whenever you like. In UMG, in Level Blueprint or in GameMode/GameState/GameInstance. I don’t think I need to show you guys where to put them. It’s easy to find those places. Try to make it by yourself.

I have played couple of times to check how many data Google can give me.

Behavior is updating with one day lag but it’s really great!

Behavior

I can see exactly where players goes and I can go even further:

sitecontent

Which gives me a lot of data to think about.

I can check what people are doing at Summary Screen:

summary

Do to this simply filter out the data:

filter

So I was restarting game from summary more often than watching leaderboards.

Basically thanks to Record Screen you can track player and get data about:

  • Time spend on screen, (eg. main menu, in-game, leaderboards)
  • On which screen players are quitting,
  • How players moves from screen to screen,
  • % views/exits in custom flow segment,

This is giving you a lot of information about what’s player doing in your game.

How players are playing

Next step is to send some custom data. Let’s first focus on Summary Screen, which can be called End Game.

I have created AnalyticsComponent which will send me End Game data. Rest of the data are so custom that can be called directly from specific blueprints.

gameended_0

Yes you will have a lot of wires to get the data from.

gameended_1

gameended_2

I’m using one Category called GameEnded it will be easier to filter data later.

Now just add AnalyticsComponent to GameplayMode and call RecordGameEnded when summary screen will popup.

Thanks to RecordGameEnded I can get tons of data:

endgame

Thanks to this I know that I was playing using pistol as ammo left for different weapons are near maximum ammo in the game. I wasn’t using aim mode a lot as well.

I can check if player complete level or dies:

die

Hope you get the point. Gather all data that’s needed. First ask yourself what kind of things you need to know about players when they end the level. 

Next category that I have created is EnemyDead, called in BP_BaseWeapon when enemy is dying.

enemydead

I know which enemies are being killed. Currently there is a lot of drones in game as you can see from Analytics.

Next I’m checking which weapon was used to kill enemy:

whichweapon

Again pistol – this means rifle and shotgun aren’t so good at all. This information motivates me to boost rifle and shotgun – now they are more deadly.

When it comes to EnemyDead I’m storing death body hits as well. To see how players are aiming:

diehitbody

Just sending name of physical material.

I’m storing hits on taking damage as well. Not only when enemy dies. I have created EnemyHit category with the same data, but for every enemy. Label here is enemy name.

enemyhit

Lot of wires which can’t be easily fixed. There is to much data to send.

Thanks to this I can see each enemy (Rage, Trooper, Drone etc) and check which body part it was shoot at:

ragehitbody

And by weapon:

ragehitbyweapon

Hope you get the point 🙂

The same thing goes with player. I want to know which enemies are hitting / killing player.

whocausedplayerdeath

And which enemy is causing damage:

whichenemycauseddamage

I can see damage taken:

playerdamagetakenbyenemies

Thanks to that I can rebalance enemies damages.

Another thing that I’m tracking is some weapons data. It’s in Weapons category which is storing:

  • NoAmmo (Action), WeaponName (Label)
  • Fired (Action), WeaponName (Label)
  • ReloadStarted (Action),  WeaponName (Label) – Player Health as value,
  • ReloadedFinished, (Action), WeaponName (Label) – Player Health as value,

playerfiredweapon

Again – pistol is mostly used gun by me. Not anymore 😉

Thanks to Reload I’m able to see if player is taking damage when reloading.

reload

And last thing to track for me is Aim. I want to know if people are using it and how.

aimtimeleft

And basically that’s all data I will track for now. I’m still learning Google Analytics and what’s the best way to get the data. As always take your time!

Additional Data

By using Google Analytics you can get even more data. For example:

  • Avg. Session Duration: 00:00:27
  • Sessions, Users, New Users vs Come Back users,
  • Retention fallowed by 1 day / 7 day / 14 / 30 day users,
  • Sessions count per user,
  • In which country players are playing

country

For now all data is from me but this will change during closed prototype tests.

Final Words

You should learn how to use analytics and make your games even better. Remember – always rethink how to send the data so they will give you answers not questions. Iterate this process as I will during first demo.

 

Creating ShooterTutorial takes a lot of my free time.
donateIf you want you can help me out! I will use your donation to buy better assets packs and you will be added to Credits /Backers page as well. Implementing game is taking time but writing about it is taking much more effort!

2 thoughts on “Adding Google Analytics

    • Hello, That is awesome indeed. Same question as Piotr, would it be possible to make Heatmaps, for instance by projecting the most frequent paths on the actual level map (top view) with different colours?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.