Skip to content

Instantly share code, notes, and snippets.

@jamesyoung
Created June 22, 2011 22:50
Show Gist options
  • Save jamesyoung/1041462 to your computer and use it in GitHub Desktop.
Save jamesyoung/1041462 to your computer and use it in GitHub Desktop.
Titanium Mobile Mixpanel example
function track(evt, p) {
if (Ti.Network.online) {
var track = {};
var props = {};
track.event = evt;
props.ip = Ti.Platform.id;
props.token = Ti.App.MIXPANEL;
props.time = Ti.App.date.getTime();
for (var key in p) {
props[key] = p[key];
}
track.properties = props;
e = JSON.stringify(track);
var data = String(Ti.Utils.base64encode(e));
httpGet({
url:Ti.App.TRACKING_URL+data,
callback:function(e) {
Ti.API.info("track callback : " + e)
}
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment