Last active
July 19, 2016 15:01
-
-
Save hijonathan/5738c8d24f57dfc668448ec68e3a22f5 to your computer and use it in GitHub Desktop.
See Appcues form responses in Mixpanel JQL
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 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