Share on Facebook0Tweet about this on TwitterShare on Google+0Share on Reddit0Digg thisPin on Pinterest0Email this to someone

UPDATED VERSION: Titanium Alloy iOS Android Modules: Analytics, Push Notifications – Events, User Profiles, Messaging – Google Analytics Alternative

I have recently had to move away from Google Analytics for our Titanium Alloy Mobile apps for different reasons – I finally settled on

Moving away from Google Analytics was a huge issue and I tried out many different mobile analytics providers with Titanium Alloy Modules including Yahoo`s  Flurry Mobile analytics (could not get it to work at all and super slow). I finally tried and WOW was I amazed at how well this simple mobile analytics tool works. Did I mention that it is open source with free optiions available? Analytics had a great iOS Analytics Module for Titanium Alloy in their documentation.

The Android Analytics Module for Titanium Alloy was however not as great – it was outdated, had event count amount problems, database problems and did not include segmentation tracking functions – I created and update to the original and submitted a pull request – you can find my new updated Android Module for Titanium Alloy on GitHub.

** UPDATE – I have since also added more updates, updating the SDKs to the latest SDK and adding UserData support. I have also changed the Android module to use functions as the iOS module does – thus creating matching functions and eliminating the need for Platform Specific code.

Here is a basic iOS and Android use Example below:

1. Download the iOS and Android Analytics Modules ZIPS for Titanium Alloy from the githubs 

– Android- –

– iOS –

Register your module with your application by editingtiapp.xml and adding your module.

  <module platform="iphone"></module>
  <module platform="android"></module>




var Countly = require('');
Countly.start('API_KEY',' OR');

Record Events

Set any of the following Fields in an Object

var segmentation = {device:"iPhone 4S", country:"USA"};
var eventData = {name: "keySegmentationCountSum", segmentation:segmentation, count: 1, sum: 0.99};
  • name (required) : Name of the event to track
    • (example – Track clicks on the help button “clickedHelp” )
  • count (required) : Number to increment the event in the db
    • (example – User purchases item increment by 1 )
  • sum : If the event is tied to an overall numerical data, such as a purchase, we can use sum to keep track of that
    • (example – 0.99)
  • segmentation : Categorization of the event
    • (example – User is from USA and uses an iPhone 4S so the segmentation will be {device:”iPhone 4S”, country:”USA”} )

Track Events Examples

var segmentation = {device:"iPhone 4S", country:"USA"};

Ti.API.log("Send keyCount Event");
var eventData = {name: "keyCount", count: 1};

Ti.API.log("Send keyCountSum Event");
var eventData = {name: "keyCountSum", count: 1, sum: 0.99};

Ti.API.log("Send keySegmentationCount Event");
var eventData = {name: "keySegmentationCount", segmentation:segmentation, count: 1};

Ti.API.log("Send keySegmentationCountSum Event");
var eventData = {name: "keySegmentationCountSum", segmentation:segmentation, count: 1, sum: 0.99};

Set UserData

Set any of the following Fields in an Object

*Set userData{} as information about user *Possible keys are:

  • name – (String) providing user’s full name
  • username – (String) providing user’s nickname
  • email – (String) providing user’s email address
  • organization – (String) providing user’s organization’s name where user works
  • phone – (String) providing user’s phone number
  • picture – (String) providing WWW URL to user’s avatar or profile picture
  • picturePath – (String) providing local path to user’s avatar or profile picture
  • gender – (String) providing user’s gender as M for male and F for female
  • byear – (int) providing user’s year of birth as integer
var userData = {    name: "testName",
username: "testUsername",
email: "testemail",
organization: "testOrg",
phone: "testPhone",
picture: "",
picturePath: "/images/appicon.png",
gender: "M",
byear: "1980",

*Set customUserData{} as information about user with custom properties *In customUserData you can provide any string key values to be stored with user

var customUserData = {  key1: "value1",

*Set Userdata as set in userData and customData *Can contain both userData and customData – or just userdata

Ti.API.log("Set UserData");
var args = {    userData:userData,

If you enjoyed this post, why not leave a comment or consider a Donation as a token of your appreciation. If you need help implementing something you saw on this site or any other project why not Hire Me?
Titanium Alloy iOS Android Modules: – Google Analytics, Flurry Alternative – Android Module Updated – Segmentation Event Tracking – Example
Tagged on:                                                                                                                                                                                 

Leave a Reply

Your email address will not be published. Required fields are marked *

Loading Facebook Comments ...