How can i add gameanalytics to my IOS build?

How can i add gameanalytics to my IOS build?


How can i implement Gameanalytics and facebook sdk so it works on ios?.

Long version:

My plan is to use Cocos creator so i can create games for Facebook Instant games, IOS and android.
The problem is most my clients ask for Gameanalytics and facebook sdk for testing retention and stuff.
Usually i was working with unity because the sdk is the same for IOS and android.
For cocos there is just this
but it says cocos creator html5


Did you find a solution?


Nop, i did not


Thats kind of blocker for me, I can’t use CC to develop games. Publisher needs FB and GA SDK’s, mandatory. What should I do? What you will do?


Actually it is very easy, I added FB and GA to our game for Voodoo publisher. You can follow GA Instruction and add it over xcode. It will take only 15 minutes, really :+1:


Yes that is how you add the library. But if the library is added on xcode and called using c-objetive, how do you make the event calls (game start and game end) from the js/typescript code if the lib is c-objective?

  • Just open the xcode and your build project


  • Add (drag & drop) the GA framrwork file to Frameworks folder which is located left side

  • Open “/ios/” file and call the GA library

import <GameAnalytics/GameAnalytics.h>

  • Add another code file for initiliaze the GA

[GameAnalytics setEnabledInfoLog:YES];
[GameAnalytics configureBuild:@“YOUR_BUILD_ID”];
[GameAnalytics initializeWithGameKey:@“YOUR_KEY” gameSecret:@“YOUR_SECRET”];

Actually you don’t need to call custom event in GA. You should only initialize GA and it will start to track your game. If you need custom event, you have to write object-c class/function into xcode and call it from javascript. (Javascript & Object-C reflection)


Thank you for this. It is really helpful. But if you work for voodoo you are required to record * GameAnalytics.NewProgressionEvent(GAProgressionStatus.Start, "Begin) and th end with the score, that is why i asked, but i guess that oc-reflection should work


@Andres_IC himm okay,
oc-reflection will be work for you. I’m already using for Applovin and some native functions (like vibration, etc.)


Hey friends!

I’ve managed to run “Gameanalytics JS SDK” on Cocos Creator for all platforms (not just for HTML5). Tested on Android and Win32. (23.6 KB)

This is the modified version of “GameAnalytics.node.js” in JS SDK.

Normally it requires window.navigator for several functions but we don’t have in Cocos Creator.
I’ve defined them with regular data:

navigator.appName = …
navigator.appVersion = …
navigator.userAgent = …
navigator.vendor = …
navigator.platform = …

replaced “localStorage” with “cc.sys.localStorage” and several fixes.


//Require at the beginning of your component script
require("gameanalytics"); // defines for global usage

// then you can use like this:
ga.GameAnalytics.initialize("...", "...");
ga.GameAnalytics.addProgressionEvent(ga.EGAProgressionStatus.Start, "World01", "Level01","Section01");
// you can check any time if it initialized correctly 
if (  ga.GameAnalytics.isSdkReady(true, false) ){
     // do whatever you want
// For example you can put these lines into onLoad function of your component:
// Game goes background, function () {
    ga.GameAnalytics.endSessionImmediate(); // End session

// Game comes foreground, function () {
    ga.GameAnalytics.startSession(); // Start session

Let me know what do you think?


This should be integrated or pinned


how can i used it with typescript?


I don’t have any experience on typescript.