Last active
August 29, 2015 14:18
-
-
Save mixpanel-bot/0206667a379618fe73f9 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> | |
<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"> | |
<div class="mixpanel-platform-section"> | |
<div id="eventSelect"></div> | |
</div> | |
<script> | |
var eventsArray = ['Signup']; | |
var eventSelect = $('#eventSelect').MPEventSelect(); | |
var runQuery = function(events) { | |
console.log('Making a funnel query with events:', events); | |
// Call the funnel endpoint passing events | |
// If events is ['A', 'B', 'C'], this is equivalent to calling | |
// MP.api.funnel('A', 'B', 'C') ... | |
MP.api.funnel.apply(MP.api, events).done(function(funnelData) { | |
console.log('Results:'); | |
console.log(funnelData); | |
}); | |
}; | |
// Do an initial query to render the first event node | |
runQuery(eventsArray); | |
// When the event select changes, re-query and re-render | |
eventSelect.on('change', function() { | |
var event = eventSelect.MPEventSelect('value'); | |
// Only add events that we aren't already querying on | |
if (!_.contains(eventsArray, event)) { | |
eventsArray.push(event); // add the new event to our events array | |
runQuery(eventsArray); | |
} | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment