Main objective of this blog post is to give you an idea about how to use Google Analytics Integration in Android and iOS.


Google Analytics is a service provided by Google that gives the statistics about your game’s traffic and traffic sources. It also measures the conversions and sales.


Step 1 Google Analytics Setting


1.1 Create Account

Create a Google Analytics Account (by simply using Gmail account) and fill up the details as shown in screen-shot below:

  • Go to admin tab and create a new property.



1.2 Set Property

Next, specify what would you like to track. After filling all the required details, track id will be generated (that will be used to track statistics).


1.3 Tracking ID

A tracking id will be generated if all the details filled are appropriate(it will be used further).


Step 2 Integrate SDK with your Game



Step 3 Configure plug-in of Your Project


3.1 For Android

  • In order to configure tracking services, there must be an android AndroidManifest.xml file. If there is no manifest file build game for android and that will generate the AndroidManifest.xml file in Temp\StagingArea. Copy the file and paste it in Assets/Plugins/Android/ folder.
  • The following two permissions should be in AndroidManifest.xml file, add these permissions if they are not added.

3.2 For iOS

  1. Add libraries to your Xcode project:
    • AdSupport.framework
    • CoreData.framework
    • SystemConfiguration.framework
    • libz.dylib libsqlite3.dylib
  2. Copy the file PostProcessBuildPlayer_GA from the iOS Extras directory and put it in the /Assets/Editor directory.
  3. Download the script and copy it into the Editor directory.
  4. Set your GAv3 object
    • Take Gav3 prefab object from the Google Analytics folder.
    • You can use the same property ID for all the platforms.
    • Dispatch Period, Sample Frequency, Debug Mode, Anonymize IP and Dry Run can be used as its default property.



Step 4 Track an object

  1. Decide an object which you want to track, say player.
  2. Add public object reference of GoogleAnalyticsV3 in player script (player script is dropped on player object)
  3. Initialize that object with prefab (GAv3) that is configured.

4.1 Tracking events and screens

  • Tracking will be in various parts.
  • It will show active users, new users, top devices model, etc...
  • You can also define screen and event tracking which will track if the user is on any specific screen or some specific event is fired in the game.



4.2 Add event for tracking

  • If you want to track users according to chips/credits follow the given code:
    private int calculateGoogleAnalyticsEvent()
         intEventNumber = 0;
         if (GLOBAL.totalCredit >= 0 && GLOBAL.totalCredit < 100000)EventNumber = 1;        
         else if (GLOBAL.totalCredit >= 100000 && GLOBAL.totalCredit < 1000000)            
         EventNumber = 2;                    
         else if (GLOBAL.totalCredit >= 1000000 && GLOBAL.totalCredit < 10000000)            
         EventNumber = 3;        
         else if (GLOBAL.totalCredit >= 10000000 && GLOBAL.totalCredit < 100000000)            
         EventNumber = 4;        
         else if (GLOBAL.totalCredit >= 100000000 && GLOBAL.totalCredit < 500000000)
         EventNumber = 5;
         return EventNumber;
    int eventNumber = calculateGoogleAnalyticsEvent();
    googleAnalytics.LogEvent("Category_" + eventNumber, "Action_" + eventNumber, event

4.3 Add screen tracking

  • To track users according to screen, the following code should be added:
if (GLOBAL.selectedTheme == 1) googleAnalytics.LogScreen("Stage 1 Level " + GLOBAL.getLevelNumber()); if (GLOBAL.selectedTheme == 2) googleAnalytics.LogScreen("Stage 2 Level " + GLOBAL.getLevelNumber()); if (GLOBAL.selectedTheme == 3) googleAnalytics.LogScreen("Stage 3 Level " + GLOBAL.getLevelNumber());

I hope you will find this blog post very useful while using with Google Analytics Integration in Android and iOS. Let me know in comment if you have any questions regarding in IOS. I will reply you ASAP.

Got an Idea of Android and iOS Game Development? What are you still waiting for? Contact us now and see the Idea live soon. Our company has been named as one of the best iOS Game Development and Android Game Development.

I am game programmer, always had keen interest in games which lead me to learn and develop games. I’ve been developing games for over a year. I develop games using andangine for android and unity3d for all platform compatibility.

face mask Belial The Demon Headgear Pocket Staff Magic