Countly is a fantastic open source stat tracking application and a good alternative for those wishing to take control of their own statistical data produced from apps.
Countly-Corona is a lua interface to Count.ly enabling you to use it in your Corona SDK applications.
- Corona-Countly uses GGData to aid with disk caching when offline. Clone that repository and copy GGData.lua into a subdirectory of your Corona application called util.
- Copy countly.lua into the util directory as well
When you are done, your files should look like this:
Corona_Project |-util |- GGData.lua |- countly.lua |-main.lua
First, import the countly module into main.lua
local Countly = require("util.countly")
Then initialize counlty with your application key and url
Countly:startWithHost("APP_KEY","http://yourappaddress.com")
Again, make sure that the countly module is imported for any file you want to track an event for.
local Countly = require("util.countly")
Then use one of the following methods:
Countly:recordEventCount(key, count)
Countly:recordEventCountSum(key, count, sum)
Countly:recordEventCountSegmentation(key, count, segmentation)
Countly:recordEventCountSumSegmentation(key, count, sum, segmentation)
Here is an example of each:
-- Simple count
Countly:recordEventCount("game_started", 1)
-- Simple sum
Countly:recordEventCountSum("time_spent_hacking", 1, 13.37)
-- Using segmentation
Countly:recordEventCountSegmentation("choose_your_player", 1, { ["player"] = "Mario" })
- App Version: I wasn't sure how to determine this with Corona
- Carrier: I wasn't sure how to determine this
If you know how to determine either above, I'd really appreciate a pull request.