Skip to content

Instantly share code, notes, and snippets.

@joshjensen
Last active December 16, 2015 08:18
Show Gist options
  • Save joshjensen/5404361 to your computer and use it in GitHub Desktop.
Save joshjensen/5404361 to your computer and use it in GitHub Desktop.
Cross-platform Appcelerator Titanium example for Count.ly
var apiKey = "ENTER YOUR COUNTLY KEY HERE";
var countly = null;
var isAndroid = (Ti.Platform.osname === 'android');
if (isAndroid) {
countly = require('ly.count');
countly.countInit(VARS.GV.statsServer, apiKey);
} else {
countly = require('count.ly');
countly.start(apiKey, VARS.GV.statsServer);
}
exports.event = function(_args) {
if (isAndroid) {
countly.sendEvent(_args.name, _args.count);
} else {
countly.event(_args);
}
};
Install required modules
Android - https://github.com/shivakumars/Titanium-Android-Count.ly/blob/master/dist/ly.count-android-0.1.zip
iOS - https://github.com/euforic/Titanium-Count.ly/blob/master/count.ly-iphone-0.2.1.zip
To use the modules you can use this example:
var countly = require('analytics');
countly.event({
name: 'App | Installed'
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment