From the EA 1.99.260 and next 1.4 Beta update onwards of GameMaker: Studio, analytics for Android and iOS are no longer provided natively and instead are now available as extensions. If you are using the built-in analytics functions currently, you will need to remove them and instead add in the new extension functions, which we will explain below.
The extensions are supplied to you in the form of Demo files, and from these you can test the extensions then create your own GMEZ for future projects to use. The demo files are available from the YYG Demo RSS feed, which you can access from the startup screen of GameMaker: Studio.
Once you select the demo to download, it will be loaded into GameMaker: Studio ready for you to test.
Once you load the Demo file, you can open the extensions resource from the tree on the left and see the new functions that have been added for each platform (Flurry or Google). For example, you can see the full list of new functionality for Google Analytics in the next image:
Functionally the two analytics providers are similar but of course there are still differences (Google Analytics has an extra function). Where there is an overlap in what the provider allows we've kept the setup as much the same as possible. This means you could change from one analytics provider to another very easily in your game just by dropping in the new .gmez and then replacing the provider name in all function names and that would be the only change you'd likely need.
As you go through each demo, please check the Helpfile that is bundled with the demo for more information, as it will explain if there are any build requirements or obvious pitfalls to be aware of. You can find the helpfile from the Included Files in the resource tree, as shown in the image below:
You can open the helpfile by right clicking on the resource and selecting "Open in Explorer". Once you've had a read of the Helpfile, you should retrieve your tracking ID values from the respective analytics provider. Note that you will need to provide different keys for Android and for iOS, so make sure you have set up two different projects to track in the analytics provider dashboard for your game.
Once you have your tracking Ids you can add them into the Create Event code of the "objControl" object and test the demo on your chosen device. Note that for Android, you need to do a full APK build for them to work. Since there is no direct feedback with analytics, the demo itself will only display console messages to show the status of the analytics events called, however if you are testing with Google analytics, the real-time reporting on the website has improved, and you can now see events as they are triggered which is very handy for testing. It shows results almost straight away for iOS, but for Android it can take a while for something to show up because the android SDK only dispatches results intermittently.
If you want to see exactly how the extension is made up, or you wish to customise any of the functionality (or add new stuff - the demo is done now and we've matched and even exceeded what the in-built functions offered previously, so if you want something extra you'll likely have to write it yourself using the provider's own SDK documentation), you will need to explore the source code.
To do this, right-click the extension in the tree and choose Open Extension Directory:
<img style="display: block; margin-left: auto; margin-right: auto;" src="http://help.yoyogames.com/attachments/token/PF1gYwmTvMBbW3DuyMRGtNAWM/?name=AnalyticsExtExplore.png" alt="AnalyticsExtExplore.png" />
This will open a new Explorer window on the Extension files, and inside this folder you will find the two subfolders for iOS and/or Android (plus whichever platforms your extension may cover):
<img style="display: block; margin-left: auto; margin-right: auto;" src="http://help.yoyogames.com/attachments/token/C96jzjlFLmCODWZe0nU41fUQh/?name=AnalyticsSource.png" alt="AnalyticsSource.png" />
Inside those folder you will see the structure for the extension, plus the source code itself. Understanding the new languages is far too large a topic to go into here, but you will see Android extensions use Java .java files and iOS uses Objective-C .h header files and .mm implementation files. Feel free to have a read through the code and make changes if you wish.
Once you're happy with testing the demo and you've understood what's going on with the code, you should export the extension out for use in your own project. To do this, you must use the .gmez format, not the legacy GameMaker .gex extension type. Simply right-click the extension entry in the tree and choose Export extension from the context menu, as shown below:
<img style="display: block; margin-left: auto; margin-right: auto;" src="http://help.yoyogames.com/attachments/token/uTwghwQJaNDANAItYhHzLqzCu/?name=AnalyticsExport.png" alt="AnalyticsExport.png" />
This will give you a save dialogue, so pick a location and your new file will be written out. Locate the file and you'll be ready for the next stage.
To use the extension in your own games, simply import the extension by right clicking the Extensions resource tree and selecting "Import Extension" and browse to where you made the .gmez. Once the extension is added, you will need to initialise the extension functions in your game - this only needs done once, so you would do this in the first instance of the first room, and can use the Game Start event, for example - with the following code:
<img style="display: block; margin-left: auto; margin-right: auto;" src="http://help.yoyogames.com/attachments/token/xfWeLJXpKixNqDntJbF865Osg/?name=AnalyticsCode1.png" alt="AnalyticsCode1.png" />
As you can see, this will select the correct tracking ID to initialise based on the OS that is running the game. If you are only making an iOS or only making an Android game then you can omit the OS check and simply use the init function your tracking ID.
You can then add the following code at the points in your game where you require an event to be sent to the analytics provider (for example at the start of a new level, or when the player dies, etc...):
<img style="display: block; margin-left: auto; margin-right: auto;" src="http://help.yoyogames.com/attachments/token/eBO4y58XjCi3E1CJtjIW1uzqM/?name=AnalyticsCode2.png" alt="Analytics_Code2.png" />
You can use the other analytics functions in exactly the same way (see the helpfile for the correct arguments), with the _ext functions permitting additional data to be sent along with the event. Don't forget that if you are updating an existing game, you will need to swap out the legacy functions for the extension functions, as they cannot be used together without getting errors.
So now you've had a look at the demo, figured out how it works, and seen a quick example of how to integrate an extension into a new project. You should hopefully be able to quite quickly drop any of the analytics providers into your own game. Note that it's perfectly fine to include multiple analytics providers as extensions in one project - Flurry for your iOS release, Google for your Android version, for example - as they use unique function names. Just make sure that your code checks the OS and uses the appropriate function call.