Created
August 14, 2015 07:21
-
-
Save kohiomobz/93046c386cb46792a48b to your computer and use it in GitHub Desktop.
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
<!doctype html> | |
<html> | |
<head> | |
<link rel="stylesheet" type="text/css" href="https://cdn.mxpnl.com/libs/mixpanel-platform/css/reset.css"> | |
<link rel="stylesheet" type="text/css" href="https://cdn.mxpnl.com/libs/mixpanel-platform/build/mixpanel-platform.v0.latest.min.css"> | |
<script src="https://cdn.mxpnl.com/libs/mixpanel-platform/build/mixpanel-platform.v0.latest.min.js"></script> | |
</head> | |
<body class="mixpanel-platform-body"> | |
<div id="table"></div> | |
<script> | |
MP.api.ready(function() { | |
var dauEventName = 'user-info: Session end'; | |
var revenueEvent = 'revenue: in app purchase'; | |
var revenueProp = 'number(properties["_Revenue Revenue"])'; | |
var dauParams = { | |
'unit': 'day', | |
'type': 'unique', | |
'from': moment().subtract(30, 'days') | |
} | |
var $dau = MP.api.events(dauEventName, dauParams); | |
var $revenue = MP.api.segment(revenueEvent, revenueProp, {from: moment().subtract(30, 'days'), method: 'sum'}); | |
$.when($dau, $revenue).done(function(dau, revenue){ | |
var dauValues = dau.values(); | |
var revenueValues = revenue.values(); | |
console.log(dauValues, revenueValues); | |
var data = { | |
'ARPDAU': { | |
} | |
}; | |
_.each(_.keys(dauValues[dauEventName]), function(key){ | |
if (key in revenueValues && revenueValues[key] && dauValues[dauEventName][key]) { | |
data['ARPDAU'][key] = revenueValues[key] / dauValues[dauEventName][key]; | |
} | |
}); | |
var chart = $('<div></div>').appendTo('body').MPChart({chartType: 'line'}); | |
chart.MPChart('setData', data); | |
}); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment