Created
June 22, 2011 22:50
-
-
Save jamesyoung/1041462 to your computer and use it in GitHub Desktop.
Titanium Mobile Mixpanel example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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