Getting a good understanding of what your users are doing in your game and how often they come back to play can be critical to the success of a game. Defold provides key metrics such as daily users, installs and retention out of the box through the project dashboard. Additionally the Facebook SDK provides the facebook.post_event() function with which it is possible to create user funnels and drill down into user behaviour.
The above two solutions are often enough, but sometimes you want even more data. Perhaps you wish to track application crashes, load times or device specific metrics, in which case Google Analytics is a good choice. Google Analytics support in Defold has been requested both here on the forum and on Slack, but up until now there has been no implementation of the Google Analytics Measurement Protocol for Lua and Defold. With that in mind I decided to create an implementation that wraps the Google Analytics Measurement Protocol so that you guys can focus on making awesome games while quickly adding tracking in key parts of your game.
@britzl
Thank you for your work!
It’s really cool.
It’s working on desktop without problem, but on android I recive next error:
ERROR:SCRIPT: googleanalytics/internal/file.lua:43: unable to generate a unique filename
stack traceback:
[C]: in function 'tmpname'
googleanalytics/internal/file.lua:43: in function 'save'
googleanalytics/tracker.lua:31: in function 'get_uuid'
googleanalytics/tracker.lua:58: in function 'create'
googleanalytics/ga.lua:37: in function 'get_default_tracker'
yes, same error RESULT_CONNREFUSED
but from other phone or from mac - all fine, I think it’s some android “improvements” from china developers =)
Hmm, odd. The library is using “app” as data source. I would have expected this to result in hits being categorised as mobile. I’ll look into it. Perhaps I need to set a user agent or something.
Hmm, the non-realtime data that is collected seems to be correct. I see only Android and iOS visitors. Manually setting the User-Agent does nothing in the real time view… very strange.