Skip to content

Instantly share code, notes, and snippets.

@hijonathan
Last active July 19, 2016 15:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hijonathan/5738c8d24f57dfc668448ec68e3a22f5 to your computer and use it in GitHub Desktop.
Save hijonathan/5738c8d24f57dfc668448ec68e3a22f5 to your computer and use it in GitHub Desktop.
See Appcues form responses in Mixpanel JQL
function main() {
var date = new Date(),
prev30Date = new Date(date - 30*24*60*60*1000),
today = `${date.getFullYear()}-${date.getMonth() + 1}-${date.getDate()}`,
prev30 = `${prev30Date.getFullYear()}-${prev30Date.getMonth() + 1}-${prev30Date.getDate()}`;
return Events({
from_date: prev30,
to_date: today,
event_selectors: [{event: "Form Submitted (Appcues)"}]
})
.filter(function(event) {
// Get only form submissions.
return event.properties.interactionType === 'submit' && event.properties.interaction.category === 'form';
})
.map(function(event) {
// Format each response.
var result = {
flowId: event.properties.flowId,
id: event.properties.distinct_id,
email: event.properties.$email
};
var responses = event.properties.interaction.response;
if (Array.isArray(responses)) {
responses.forEach(function(resp) {
result[resp.label] = resp.value;
});
}
return result;
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment