Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Step two in Mixpanel Platform's DAU/MAU by country tutorial
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<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">
<script>
var eventName = 'Button clicked'; // replace with event name of your choice
var $dau = MP.api.segment(eventName, 'mp_country_code', { // use segment query on eventName, and segment the data by country
from: moment().subtract(30, 'days'), // 'from' date should be one month ago
to: moment().subtract(1, 'days'), // 'to' date should be yesterday; partial data for today impacts DAU more than it does MAU
unit: 'day', // we want the number of button clicks for each day of the month
type: 'unique' // daily counts should be unique; multiple clicks by the same person in one day should be counted only once
});
$dau.done(function(results) {
console.log(results.values());
});
var $mau = MP.api.segment(eventName, 'mp_country_code', { // use segment query on eventName, and segment the data by country
from: moment().subtract(30, 'days'), // 'from' date should be one month ago
to: moment().subtract(1, 'days'), // 'to' date should be yesterday; partial data for today impacts DAU more than it does MAU
unit: 'month', // we want the number of button clicks that occured over the month
type: 'unique' // multiple clicks by the same person during any point in the month should be counted only once
});
$mau.done(function(results) {
console.log(results.values());
});
</script>
</body>
</html>
@diegodotta

This comment has been minimized.

Copy link

@diegodotta diegodotta commented Jun 9, 2016

Is not working! 👎

@bluevakili

This comment has been minimized.

Copy link

@bluevakili bluevakili commented Sep 20, 2017

Still not working?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment